# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['lta', 'lta.commands', 'lta.helpers']

package_data = \
{'': ['*']}

install_requires = \
['ConfigArgParse>=1.5.2,<2.0.0', 'numpy>=1.21.1,<2.0.0', 'pandas>=1.3.1,<2.0.0']

extras_require = \
{':python_version < "3.8"': ['typing_extensions>=3.10.0.0,<4.0.0.0']}

entry_points = \
{'console_scripts': ['lta = lta.cli:main']}

setup_kwargs = {
    'name': 'lipidta',
    'version': '0.12.3',
    'description': 'Lipid Trafficking Analysis',
    'long_description': '# Lipid Traffic Analysis\n\n[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![CI/CD](https://github.com/IMS-Bio2Core-Facility/lta/actions/workflows/cicd.yaml/badge.svg)](https://github.com/IMS-Bio2Core-Facility/lta/actions/workflows/cicd.yaml)\n[![codecov](https://codecov.io/gh/IMS-Bio2Core-Facility/lta/branch/main/graph/badge.svg?token=2TGYX69U3N)](https://codecov.io/gh/IMS-Bio2Core-Facility/lta)\n[![Documentation Status](https://readthedocs.org/projects/lta/badge/?version=latest)](https://lta.readthedocs.io/en/latest/?badge=latest)\n[![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![Codestyle: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n**aka LTA, aka LipidTA**\n\nA python commandline interface for analysing lipidomics data.\n\nThe source code lives on [github][github].\n\nThe documentation lives at [ReadTheDocs][readthedocs].\n\nThe project can be installed from [PyPI][pypi].\n\n## Abstract\n\nLipid Traffic Analysis (LTA) is a tool for using lipidomics data to test hypotheses about how metabolism is controlled.\nLipidomics data from several, metabolically connected tissues from control and experimental groups\ncan be used to plot the spatial or temporal distribution of lipids.\nThese distributions identify where changes in lipid metabolism occur and in which lipid pathways,\nindicating the locus and biochemical alterations that occur in a given phenotype.\nLTA was conceived in two parts.\nOne is an Abundance Analysis,\nin which the error-normalised fold change (ENFC) for the control and given phenotype group is calculated.\nBecause the ratio of the control and experimental values is scaled by the error,\nthe ENFCs are easy to plot and compare between compartments.\nThe second part is a Switch Analysis.\nThis computes the presence of variables across the network.\nCurrent development is focused on developing the technique for complex networks and on the rate of lipid transport.\n\n## Using LTA from the command line\n\n### Installation\n\n#### Installing from PyPI\n\nThis is the most straightforward way to set up the tool.\nWhen installing from PyPI,\nwe strongly reccomend using a virtual environment.\nThere are many ways to do this!\nIf you already have a preferred method -\nI use [pipx][pipx] for command line tools -\nfeel free to use that.\nOtherwise,\nuse the builtin Python module [venv][venv].\nThe exact instructions are OS-specific and detailed at the above link.\nInstructions for installing the most recent version of LTA on MacOS are given below:\n\n```shell\n# Make a directory for the project\nmkdir lta && cd lta\n# Create the virtual environment\npython3 -m venv .venv\n# Activate the environment\nsource .venv/bin/activate\n# Install lta\npip install -U LipidTA\n```\n\n```{note}\nOur pip package is `LipidTA`.\nUnfortunately,\n`lta` was "too similar to existing package names",\nso PyPi wouldn\'t let us use it.\n```\n\nIf you want to install a specific version,\nthen change the last line in the previous code block to:\n\n```shell\npip install LipidTA==0.12.1\n```\n\nreplacing the version number with the version number you want.\nA list of all released versions can be found at our [tags][tags].\n\n#### Installing from Source\n\n```{important}\nMost users **will not need** these instructions.\n```\n\nIf you need to customise the code in some manner,\nyou\'ll need to install from source.\nTo do that,\neither clone the repository from github,\nor download one of our releases.\nFor full instructions,\nplease see our guide on [contributing](./contributing.md).\n\n(data)=\n\n### The Data\n\nThis should be a single CSV files where the first 11 rows contain sample metadata\nand the first 3 columns contain the lipid metadata.\nWithin the sample metadata,\nrows 4-9 should contain the:\n\n- Mode (*ie.* -ve vs +ve)\n- Sample ID\n- Phenotype (*ie.* lean vs obese)\n- Generation (*ie.* F1 vs F2)\n- Tissue (*ie.* heart)\n- Handling (any notes about sample prep)\n\nrespectively.\nYou can name these metadata rows whatever you want,\nand tell ``lta`` where to find them with the appropriate flags.\nPlease see the section on [customising your run](customising).\nIn order to read the data,\nsome assumptions about the format must be made.\nShould we make any changes to data format expectations,\nit will be well documented and will only occur in a major/breaking releas.\n\n```{note}\nWe hope to generalise file reading in future releases to improve usability\nin a future release.\n```\n\n### Running the analysis\n\nOnce you\'ve installed the tool and activated your virtual environment,\nrunning the analysis is as simple as:\n\n```shell\nlta data.csv results\n```\n\nThe first argument is path to the combined input file.\nIf the file doesn\'t exist,\nis a directory,\nor doesn\'t contain any data files,\nthe command will error with an apropriate message.\nThe secont argument identifies a folder in which the results will be saved.\nIt will be create if it doesn\'t exist.\n\nIf you ever have any questions about the tool,\nyou can access a condensed help menu by running:\n\n```shell\nlta -h\n```\n\n(customising)=\n\n#### Customising\n\nThere are a few options that can be customised for any given run.\nThe statistics are calculated using a bootstrapping approach,\nwhich (by definition) involves repeated replicates.\nTo control the number of replicates,\npass the ``-b/--boot-reps`` flag with a number.\nGenerally, more reps improves the accuracy of the estimates,\nthough I find little improvement beyond 20,000 reps.\n1000 (the default number) seems to provide a good balance between speed and accuracy.\n\nA critical step of the analysis is binarizing the lipid expression.\nA lipid is classed as 0 in a tissue/condition if\nthe lipid is **not** detected in more than a particular fraction of samples.\nThe default values is 0.2 (one-fifth of the samples).\nIf you want to change it,\npass the ``-t/--threshold`` flag with a decimal between 0 and 1.\nThis value can have a significant impact on the analysis,\nso explore how it impacts your data!\n\nMany calculations are dependent on knowing where certain metadata is stored.\nNamely, the experimental conditions (specified with ``--phenotype``)\nthe tissue of origin (specified with ``--tissue``),\nand the lipidomics mode (specified with ``--mode``).\nIf these are not passed,\nthen they default to "Phenotype", "Tissue", and "Mode" respectively.\nPlease the section on [expected data file structure](data) for more information.\n\nFor the fold-change calculation in ENFC to make any sense,\nwe need to know which group in ``phenotype`` is which.\nYou can specify this using the ``--order`` option like so:\n\n```shell\nlta data results --order obese lean\n```\n\nThe first word following order will be treated as the experimental group,\nwhile the second word will be treated as the control group.\nIn this example then,\nfold-change would be give as ``obese / lean``.\nIf you don\'t specify,\nthis defaults to ``experimental / control``.\n\nIf you find yourself regularly passing arguments via the CLI,\nyou might want to try a configuration file!\nThis is a simple text file that stores options in a simple format:\n\n```shell\noption=value\n```\n\nBy default,\nLTA looks for ``lta_conf.txt`` in your current directory.\nHowever,\nyou can name this file whatever you want,\nand let LTA know where to find it,\nby passing the config flag like so:\n\n```shell\nlta -c path/to/your/config.txt data results\n```\n\nIf you specify an option in the configuration file,\nthat will override LTA\'s defaults,\nand specifying an option at the command line will override the configuration file!\nThe config file doesn\'t need do exist, however,\nand is just a bit of sugar.\n\n### The Output\n\n```{warning}\nRe-running the analysis overwrites existing results,\nso be sure to either back up your data,\nor pass a different output folder!\n```\n\nThe output folder will contain 5 file.\nFor each type of lipid, you should see the following:\n\n1. ``enfc_individual_lipids.csv`` - the ENFC results for each lipid.\n1. ``enfc_lipid_classes.csv`` - the mean and St.Dev. of ENFC, grouped by lipid class.\n1. ``switch_individual_lipid.csv`` - a table of lipids and their A/B/U/N classification.\n1. ``switch_lipid_classes.csv`` - a table counting the frequency of each lipid class within the A/B/U/N classification.\n1. ``jaccard_similarity.csv`` - the Jaccard similarity and p-value for each lipid class.\n\nA few notes!\nFold change will **always** be ``order[0] / order[1]``.\nThe Jaccard distances are calculated between conditions specified in ``--phenotype``\nacross both tissues and lipid classes.\nThe p-values for these distances are calculated using the method outlined by\n[N. Chung, et. al.][jaccard].\nFor ENFC,\nfold change is only meaningful if both values are non-0.\nWhere this is *not* true,\nNaN has been substituted,\nleaving an empty cell in the output.\n\n## Contributing\n\nOpen-source software is only open-source becaues of the excellent community,\nso we welcome any and all contributions!\nIf you think you have found a bug,\nplease log a report in our [issues][issues].\nIf you think you can fix a bug,\nor have an idea for a new feature,\nplease see our guide on [contributing](./contributing.md)\nfor more information on how to get started!\nWhile here,\nwe request that you follow our [code of conduct](./coc.md)\nto help maintain a welcoming,\nrespectful environment.\n\n## Future Developments\n\n- [x] Improve Github actions to use caching for poetry and Nox\n- [ ] Increase test coverage\n- [ ] Automate plotting\n\n## Citations\n\nIf you use LTA in your work,\nplease cite the following manuscripts:\n\n1. Furse, S., Watkins, A.J., Hojat, N. *et al.* Lipid Traffic Analysis reveals the impact of high paternal carbohydrate intake on offsprings’ lipid metabolism. *Commun Biol* **4**, 163 (2021). [https://doi.org/10.1038/s42003-021-01686-1][paper_1]\n1. Furse, S.[^eq], Fernandez-Twinn, D.S.[^eq], *et al.* Lipid metabolism is dysregulated before, during and after pregnancy in a mouse model of gestational diabetes. *Int. J. Mol. Sci.* **22**, 7452 (2021). [https://doi.org/10.3390/ijms22147452][paper_2]\n\n[^eq]: These authors contributed equally to this work.\n\n[github]: https://github.com/IMS-Bio2Core-Facility/lta "LTA Source Code"\n[readthedocs]: http://lta.readthedocs.io/ "LTA Documentation"\n[pypi]: https://pypi.org/project/gtexquery/ "LTA PyPI Package"\n[pipx]: https://pypa.github.io/pipx/ "pipx"\n[venv]: https://docs.python.org/3/tutorial/venv.html "Python venv"\n[tags]: https://github.com/IMS-Bio2Core-Facility/lta/releases "LTA releases"\n[issues]: https://github.com/IMS-Bio2Core-Facility/lta/issues "LTA issues"\n[jaccard]: https://doi.org/10.1186/s12859-019-3118-5 "Jaccard Probabilities"\n[paper_1]: https://www.nature.com/articles/s42003-021-01686-1 "LTA citation 1"\n[paper_2]: https://www.mdpi.com/1422-0067/22/14/7452 "LTA citation 2"\n',
    'author': 'rbpatt2019',
    'author_email': 'rb.patterson.cross@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/IMS-Bio2Core-Facility/LTA',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'extras_require': extras_require,
    'entry_points': entry_points,
    'python_requires': '>=3.7.1,<3.11',
}


setup(**setup_kwargs)
