{ "info": { "author": "Marek Borowiec", "author_email": "petiolus@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Bio-Informatics" ], "description": "# spruceup\n```\n A \n TCG \n ACGTA \n T \n```\n\nTools to discover, visualize, and remove outlier sequences in large multiple sequence alignments.\n\n`spruceup` is a Python tool for biologists (bioinformaticians, phylogeneticists, evolutionary biologists) doing inference on phylogenomic sequence alignments. It allows discovery and removal of individual poorly aligned sequences or sequence fragments (alignment rows), which is different from the problem of poorly aligned sequence blocks (alignment columns) commonly addressed by alignment trimming software.\n\nIf you are using this program, please cite [this publication](link):\n```\n```\n\nThis script uses [numpy](http://www.numpy.org/), [scipy](https://www.scipy.org/index.html), [matplotlib](https://matplotlib.org/), [psutil](https://pypi.org/project/psutil/), [tqdm](https://pypi.org/project/tqdm/), and [treeswift](https://pypi.org/project/treeswift/).\n\n## Installation and requirements\n\nYou can download a zipped GitHub repository, clone it if you have `git` installed on your system, or install using [pip](https://pip.pypa.io/en/latest/installing.html) from the [Python Package Index](https://pypi.python.org/pypi/spruceup). Cloning the repository will also download example files used in the tutorial below. \n\n\n`spruceup` has been developed and tested under Ubuntu Linux. It requires you have Python version 3.6 or newer. You can use `spruceup` with early releases of Python 3.7, but as of today (12 August 2019), you may experience trouble installing it if using Python 3.7.4. Dependencies should be installed automatically. If your system does not have Python version 3.6 or newer you will need to [download and install it](http://www.python.org/downloads/). On Linux-like systems (including Ubuntu) you can install it from the command line using:\n\n```bash\nsudo apt-get install python3.6\n```\n\nIt is highly recommended that you install `spruceup` in a new Python environment. If you are using the [conda package manager](https://www.anaconda.com/distribution/), type:\n```bash\nconda create --name spruceup python=3.6\n```\nAnd follow instuctions on the prompt.\n\nNow activate your environment (with `conda` you would type `conda activate spruceup`) and install. If you want to download example files, simply download and unzip this repository or, if you have git, clone it with:\n```bash\ngit clone https://github.com/marekborowiec/spruceup.git\n```\n\nYou can then install `spruceup` from within this cloned repository:\n```bash\npython setup.py install\n```\n\n`spruceup` is also available on [Python Package Index](https://pypi.org/) and you can install it via `pip` without example files:\n```bash\npip install spruceup\n```\n\nIf you do not wish to install `conda`, you can set up a new environment using a different package manager, such as `venv`:\n```bash\npython3 -m venv spruceup\n```\n\n## Interface\nOnce you successfully installed `spruceup` you will need 1) an alignment in `FASTA`, `PHYLIP` or `NEXUS` format, 2) (optional) a guide tree for your alignment in `NEWICK` format, and 3) configuration file to run the program. To run the program from the command line you can type:\n```bash\npython -m spruceup my-configuration-file.conf\n```\nDirectory `examples` contains a template configuration file (`/examples/config_example.conf`). This file should be a template for your own analyses. It has the following fields:\n\n### [input]\nThe `input` category defines parameters of the input alignment and its type.\n\n`input_file_name` is the file path of the alignment to be processed. This can be provided as a file name, if the config is in the same directory as alignment and `spruceup` command will be ran from there as well. Alternatively, you can provide the absolute path. *__This should be a relatively large, concatenated alignment__*. The `spruceup` algorithm works the better the more data it has, so if you have a phylogenomic dataset consisting of many single-locus alignments, you should first concatenate them. You can then split the processed/trimmed alignment back into single-locus alignments using another utility such as [AMAS](https://doi.org/10.7717/peerj.1660).\n\n`input_format` indicates which format the alignment file is in. It can be one of five popular formats: `fasta`, `phylip`, `phylip-int` (interleaved PHYLIP), `nexus`, and `nexus-int`.\n\n`data_type` tells the program whether your alignment contains amino acids (`aa`) or DNA nucleotides (`nt`).\n\n`distances_object_file` is the file name of an existing distance object. By default this saves to the directory where you run the `spruceup` command and so it is better to provide absolute path here. Because sometimes you will want to adjust cutoffs or cutoff criterion and computing distances is the most time-consuming part of the analysis, `spruceup` saves a `json` format file with distances from each analysis. By default this is blank, but if you do have a distance file from a previous analysis and you want to trim your alignment with new cutoffs, supply the `json` file name here. `spruceup` will then run with new trimming cutoffs and/or criterion but without the need to re-calculate distances.\n\n`guide_tree` is a phylogram or cladogram `NEWICK` format file to be used as a guide tree. File name or absolute path. The tree can be inferred using any method and can be fully resolved or contain polytomies. If you do not supply a guide tree the program will still run but without phylogeny it will have less information to identify misaligned sequences. This is particularly important in vartiable algnments with distantly related samples (individual sequences representing individual, taxon, OTU, etc.), where it is more difficult to distinguish genuinely variable sequences from misaligned fragments. In cases where you suspect and are mainly concerned with samples with spuriously long terminal branches it is adivsable to supply topology-only (cladogram) guide tree and/or run the program without a guide tree. \n\n### [analysis]\nThe `analysis` category defines parameters used to analyze and clean up your alignment.\n\n`cores` how many CPU cores to use for distance calculations.\n\n`distance_method` chooses to compute uncorrected p-distance with `uncorrected` or Jukes-Cantor-corrected distance with `jc`.\n\n`window_size` chooses how many characters (aa/nt) to include in a window in which distances will be calculated. Default value that works well for most alignments is `20`. \n\n`overlap` indicates how many characters (aa/nt) each sliding window will be overlapping with preceding window. Overlap of `15` and window size of `20` means that each new window will move 5 positions down the alignment and overlap by 15 characters with the preceding window. Decreasing the overlap will decrease computational burden because fewer windows will be created. Default value is `15` (two thirds of default window size of `20`) but you may want to go lower, to half of window size or even `0` (non-overlapping windows) if your alignment is very large and you want to decrease compute time and memory usage and don't mind sacrificing some precision. \n\n`fraction` signifies proportion of samples that will be used to calculate average distance in each window. With fraction set to `1.0` distances for each sample will be calculated against all other samples in the alignment. With fraction set to `0.5` distances for each sample will be calculated against a random draw representing 50% of samples in the alignment. Lowering this number will help to speed up calculations in alignments with large numbers of taxa.\n\n`criterion` chooses how outlier distances will be determined. `lognorm` means that a [lognormal distribution](https://en.wikipedia.org/wiki/Log-normal_distribution) will be fitted to your distance data for each sample and cutoffs will be determined by specifying quantile of observations above which sequence will be considered outliers. If you are using `mean`, simple multiple of those values computed for each sample will be considered cutoffs for identifying outliers.\n\n`cutoffs` specifies multiple values considered as cutoffs. If using `lognorm` criterion, use fractions of `1`, for example `0.9,0.995` etc. Default values that should work for most alignments are `0.9,0.95,0.97,0.99,0.995,0.999`. If you are using `mean` as your criterion, use multiples of those values, for example `5,30` etc. Defaults of `5,10,15,18,20,25,30` for `mean` criterion should be useful starting points for most datasets. You can always trim with additional criteria and cutoffs after the initial analysis (see point 5 below under Interpreting the output). If the alignment contains many saturated or poorly aligned sites, a low setting may result in huge amount of data being trimmed from the original alignment. This is time-consuming and you may want to trim your alignment with a more stringent 'block' method before using `spruceup` or remove lower cutoff values from the list.\n\n`manual_cutoffs` is an optional setting that allows manual modifications to cutoffs for individual samples. It may prove useful if only one or a few samples have a significant proportion of poorly aligned sequences, skewing their overall cutoff such that they are not being flagged. If you find that this is case, however, you should probably rather be checking your data and pipeline for errors!\n\n### [output]\nThe `output` category tells the program how and where to save your analysis results. *Remember that by default any file will be written to directory from which you executed `spruceup` command. To change this behavior provide full paths.* \n\n`output_file_aln` is the name for your trimmed output alignment(s). The actual name saved on your machine will have a prefix signifying cutoff value used.\n\n`output_format` file format for the trimmed alignment. Choose from `fasta`, `phylip`, `phylip-int`, `nexus`, or `nexus-int`.\n\n`report` name of files containing information on which sequences were flagged as outliers. The actual name will have a prefix signifying cutoff value used.\n\n`log` is the name of the log with all analysis screen output.\n\n## Examples and interpretation of results\n\nTo use `spruceup` you will need to run the `spruceup` script from the command line and provide the name of your configuration file as the argument. If you downloaded and installed `spruceup` from source, the example alignment and config files can be found in `examples` subdirectory:\n```bash\ncd ./examples\npython -m spruceup config_example.conf\n```\nThe example alignment is a subset of empirical, anonymized [ultraconseved element or UCE](https://www.ultraconserved.org/) data set generated from insects. \n\nOnce you run the script, the sequence alignment will be divided into a number of windows of the size and overlap you specified. The script will then compute distances for each sample (alignment row: the sequence representing an individual, taxon, OTU etc.) in each window. This is done all-by-all by default or all-by-fraction of samples, if specified. You will see some messages along the way, including a progress bar that will display the number of iterations (windows) and remaining time, as we as the maximum amount of memory used for distance calculation.\n\n![progress-bar](./README_files/progress-bar.png) \n \nOnce all distances are calculated, `criterion` and `cutoffs` settings will determine which windows are considered outliers and should be trimmed out of the alignment. When using the `lognorm` criterion, specifying a quantile of `0.99` means that any sequence window that lies above 99th percentile of distances of a given sample to other sample in that window will be deemed an outlier and should be removed. In theory, setting of `0.99` should mean that 1% of all sequence windows will be removed from each sample. In practice, this is not true because real-life sequence data does not perfectly fit into lognormal distribution. Cutoff being constant, certain samples may have many outlier (misaligned) sequence fragments and more than 1% of sequence data removed, while others may have no misaligned fragments and no outliers.\n\nYou can now go back to your configuration file and try other cutoffs or methods without the need to re-calculate distances (unless you would like to use different correction or scaling). Simple load the generated `json` file (see below) with the `distances_object_file` option under `[input]` category.\n\n### Interpreting output\n\n`spruceup` produces several types of output:\n\n1. Report files ending with suffix `-report.txt`, one of which is written for each cutoff specified, which indicated by the prefix (e.g `0.95`, `0.99` and so forth). These files contain the distance cutoff value for each sample and which sequence windows were determined to be outliers and removed.\n\n2. Trimmed alignment files ending with suffix `-trimmed.fas/phylip/nexus`, again, one for each cutoff value. These are the alignments with outlier windows removed.\n\n3. Distance distribution `png` plots, one for each sample and cutoff value. These images can be used to examine the distribution of distances for each taxon, its fit to lognormal distribution, and cutoff value placed on each sample given a cutoff.\n\nAn example of distances plot is below. The header is the name of the sample. The x-axis indicates distance to other samples, ranging from `0` to the maximum distance that was found for the sample. The y-axis specifies relative number of windows. Blue bars comprise the histogram of distances. Orange line is the fitted lognormal distribution (only shown when using the `lognorm` criterion) and the vertical dashed line indicates the cutoff above which any window will be deemed an outlier and removed.\n\nThe first example plot below shows an sample with relatively smooth distance distribution and few sequence windows with extreme values, none of which are greater than `0.2`. You may not be able to see individual window distances as visible histogram bars since the distributions comprise thousands (in this small example) to hundreds of thousands of distances.\n\n![example-plot-good](./README_files/example-plot-good.png)\n\nThe following plot shows a sample with less smooth distribution, overall sequences fewer sequences due to missing data, as indicated by the heigth of the histogram bars, and many outlier windows.\n\n![example-plot-poor](./README_files/example-plot-poor.png)\n\nBoth examples have been processed under the same cutoffs values, `0.95,0.97,0.99` quantiles of fitted lognormal distribution but in the poorly aligned data the last falls outside of computed distance values. These plots, combined with visual examinaton of report files and alignments should serve you as a guide on what criterion and cutoff values make most sense for your dataset.\n\n4. Log file \n\nThis is a log file that will contain the same information that appears on the terminal screen, excluding progress bar. It will log what steps were taken by the program, their timing, show information about how many/what proportion of sites were trimmed at each cutoff and output file names that were written. \n\n5. Distances Python object file\n\nCalculating distances with `spruceup` is often the most time- and memory-consuming part of the process, although trimming very large numbers of positions from the alignment can also take a long time. Because of this `spruceup` writes a `json` format file each time you run an analysis from scratch, allowing you to load it up later and trim with different criterion or cutoff values. Note that distances will be specific for each window size, overlap, and taxon fraction and you will need to re-run the whole analysis if you want to adjust these parameters. Note that the `json` file can be quite large at >150MB per 100,000 windows and 100 taxa.\n\n## Testing\n\nTests written for `spruceup` code use the Python's standard library module `unittest` and are integrated with `setuptools`. This means that if you downloaded the `spruceup` source code, you can run tests from the top `spruceup` directory after installing with:\n```\npython setup.py install\npython setup.py test\n```\nThese tests are likely to take several minutes because they include metamorphic tests (cf. [Giannoulatou et al. 2014](https://doi.org/10.1186/1471-2105-15-S16-S15)) which involve running `spruceup` on simulated data with known properties. You can speed things up by increasing the number of cores in the metamorphic test configuration file found under `tests/metamorphic_tests/simulation.conf`.\nIf you want just a quick check of basic functions, run unit tests without the time-consuming metamorphic tests. To do this, from the top `spruceup` directory run:\n```\npython -m unittest tests.test_simple\n```\n\n## Issues and development\n\nIf you encounter bugs or problems running the code, [create a new issue on GitHub](https://help.github.com/en/articles/creating-an-issue). Everyone is encouraged to [contribute](https://github.com/firstcontributions/first-contributions).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/marekborowiec/spruceup", "keywords": "alignment trimming outliers phylogenetics phylogenomics genomics bioinformatics", "license": "", "maintainer": "", "maintainer_email": "", "name": "spruceup", "package_url": "https://pypi.org/project/spruceup/", "platform": "", "project_url": "https://pypi.org/project/spruceup/", "project_urls": { "Homepage": "https://github.com/marekborowiec/spruceup" }, "release_url": "https://pypi.org/project/spruceup/2019.2.3/", "requires_dist": null, "requires_python": ">=3.6.0, !=3.7.4", "summary": "A module for lexible identification, visualization, and removal of outliers from large multiple sequence alignments", "version": "2019.2.3" }, "last_serial": 5945567, "releases": { "2019.1.1": [ { "comment_text": "", "digests": { "md5": "0751f05852a122e4ccbf765e20539dd8", "sha256": "166373a088d41c5607397d5647685b5dc1c06347948a3202e4818ba92a27c4aa" }, "downloads": -1, "filename": "spruceup-2019.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0751f05852a122e4ccbf765e20539dd8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 44652, "upload_time": "2019-07-18T23:55:08", "url": "https://files.pythonhosted.org/packages/78/2a/71440fb8cb40a938632a6d44f62f5211a401267d695bc093926129e56e79/spruceup-2019.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d65331b41bd4ba597709ac24529a701", "sha256": "94ee203727d94b8228d8d7560ad98634d1307e41cc242c465d6bf1b78f6aabbb" }, "downloads": -1, "filename": "spruceup-2019.1.1.tar.gz", "has_sig": false, "md5_digest": "2d65331b41bd4ba597709ac24529a701", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 1520398, "upload_time": "2019-07-18T23:55:21", "url": "https://files.pythonhosted.org/packages/c2/f2/2f699f88a480158f244ac0019fa2ba2b87bec018836ec7fd91ab18ee9d0e/spruceup-2019.1.1.tar.gz" } ], "2019.1.1b0": [ { "comment_text": "", "digests": { "md5": "c5cd42e4c9edc7b0e451913988bab44a", "sha256": "cd88dd00afb40f254064f1601be013953df402df96cc9845b5d7a9d66321ff48" }, "downloads": -1, "filename": "spruceup-2019.1.1b0-py3-none-any.whl", "has_sig": false, "md5_digest": "c5cd42e4c9edc7b0e451913988bab44a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0, !=3.7.4", "size": 44694, "upload_time": "2019-08-12T19:48:59", "url": "https://files.pythonhosted.org/packages/18/c1/4f4f6a7dc7245b318a4b62ade486308c3ad3a8f9be5decbb067e8124c821/spruceup-2019.1.1b0-py3-none-any.whl" } ], "2019.1.2": [ { "comment_text": "", "digests": { "md5": "d48bdd53d28b2d3e24f7cce721bb22c6", "sha256": "a61f3ea0c75ab81d9c906019002a27bdf27e59ae2fc5b239c147ecfa12fa32c5" }, "downloads": -1, "filename": "spruceup-2019.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "d48bdd53d28b2d3e24f7cce721bb22c6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0, !=3.7.4", "size": 44725, "upload_time": "2019-08-12T21:07:16", "url": "https://files.pythonhosted.org/packages/d9/2f/daa715934c4196404814872c0c39f85f6a7eab55a4d23800d68525b8adcf/spruceup-2019.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b407e3a59354ebe851501bbc6389a90a", "sha256": "c561af5239bdd6294323373cd280b340b81005e31cb560a65b85ee185ff798c9" }, "downloads": -1, "filename": "spruceup-2019.1.2.tar.gz", "has_sig": false, "md5_digest": "b407e3a59354ebe851501bbc6389a90a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0, !=3.7.4", "size": 3720161, "upload_time": "2019-08-12T21:07:38", "url": "https://files.pythonhosted.org/packages/ae/2c/0978ae347825926594d5d1087077b07831454fa9bc541334aae7b30c8b94/spruceup-2019.1.2.tar.gz" } ], "2019.2.1": [ { "comment_text": "", "digests": { "md5": "d4f29e4611f16c684c16e9c6b516592c", "sha256": "6f6904c12406646031b2227c61655b4ec11383ba7d0f92d3864c5b7d0de58fe1" }, "downloads": -1, "filename": "spruceup-2019.2.1-py3.6.egg", "has_sig": false, "md5_digest": "d4f29e4611f16c684c16e9c6b516592c", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": ">=3.6.0, !=3.7.4", "size": 40667, "upload_time": "2019-10-03T21:51:50", "url": "https://files.pythonhosted.org/packages/3d/24/2a762a4cc9a4eebbe28784fcbaf7901ab932939de48d8a18eabe2edd1425/spruceup-2019.2.1-py3.6.egg" } ], "2019.2.2": [ { "comment_text": "", "digests": { "md5": "114ae3de7cbac9659388aab0d51cdff5", "sha256": "cbd7e112b762f81d5a30743e7a17ba9ec856748a42a09df2f6910dfa41666ba7" }, "downloads": -1, "filename": "spruceup-2019.2.2-py2.7.egg", "has_sig": false, "md5_digest": "114ae3de7cbac9659388aab0d51cdff5", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": ">=3.6.0, !=3.7.4", "size": 38179, "upload_time": "2019-10-03T21:51:52", "url": "https://files.pythonhosted.org/packages/6a/c4/e51aad329d5bdff14e38b24654fcb933e62eb0a82559b4b071a3f30bd1d4/spruceup-2019.2.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "e443a0bbfb4fc9a5ef3c1e5ce3113333", "sha256": "41d78220f2fd2372e8eba52c3bae398c3898e8df61666b461905b86bdab5a5ab" }, "downloads": -1, "filename": "spruceup-2019.2.2-py3.6.egg", "has_sig": false, "md5_digest": "e443a0bbfb4fc9a5ef3c1e5ce3113333", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": ">=3.6.0, !=3.7.4", "size": 41226, "upload_time": "2019-10-08T16:22:25", "url": "https://files.pythonhosted.org/packages/ca/d5/985d641d4e502b5a6a0a27eb03343a8a1fa13fd36926f17d12d4a7e7e666/spruceup-2019.2.2-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "5ba8b93b819502a92caaa15ce75078c3", "sha256": "842e5b987d948a12ae7da701eec9901ce3f5f8aa73183d629e2774a130a68758" }, "downloads": -1, "filename": "spruceup-2019.2.2-py3.7.egg", "has_sig": false, "md5_digest": "5ba8b93b819502a92caaa15ce75078c3", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": ">=3.6.0, !=3.7.4", "size": 40991, "upload_time": "2019-10-03T21:51:55", "url": "https://files.pythonhosted.org/packages/bf/e5/b1a12a0186de57792d12e7d86452bd8735cd047165cdc559a308717f77d1/spruceup-2019.2.2-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "98738437db9842cb9c3bbe8d353de09a", "sha256": "4c8b02de3c84b3d410a73a19468dc95bdc00a1f63ae58ea5e435b49ecb92fe84" }, "downloads": -1, "filename": "spruceup-2019.2.2.tar.gz", "has_sig": false, "md5_digest": "98738437db9842cb9c3bbe8d353de09a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0, !=3.7.4", "size": 1522833, "upload_time": "2019-10-03T21:52:03", "url": "https://files.pythonhosted.org/packages/63/ec/c64d5d9baed45f2ae8b2d98db5535bd14662f2ce232a1d4ffcf7491de908/spruceup-2019.2.2.tar.gz" } ], "2019.2.3": [ { "comment_text": "", "digests": { "md5": "88ad1bf29eefd472bcc60e14ca9266d5", "sha256": "e16e73264c95c383978e218151e0898e3414ce2f2c16223a5ef1df7b73adf114" }, "downloads": -1, "filename": "spruceup-2019.2.3.tar.gz", "has_sig": false, "md5_digest": "88ad1bf29eefd472bcc60e14ca9266d5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0, !=3.7.4", "size": 1532156, "upload_time": "2019-10-08T16:22:42", "url": "https://files.pythonhosted.org/packages/77/b4/611913faead2602f5aa22132bd4cfc35354a5740118cf9a1033ca1c15f36/spruceup-2019.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "88ad1bf29eefd472bcc60e14ca9266d5", "sha256": "e16e73264c95c383978e218151e0898e3414ce2f2c16223a5ef1df7b73adf114" }, "downloads": -1, "filename": "spruceup-2019.2.3.tar.gz", "has_sig": false, "md5_digest": "88ad1bf29eefd472bcc60e14ca9266d5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0, !=3.7.4", "size": 1532156, "upload_time": "2019-10-08T16:22:42", "url": "https://files.pythonhosted.org/packages/77/b4/611913faead2602f5aa22132bd4cfc35354a5740118cf9a1033ca1c15f36/spruceup-2019.2.3.tar.gz" } ] }