Skip to content

Commit 2c3c90c

Browse files
authored
Changed import scheme for compliance with pip install (#46)
* Added arg to specify type of elements for correlogram * More verbose errors for wrong column selection in log transform * Improved parquet_to_pg to enable custom column selection before aggregation * Included pandera in pyproject.toml * Refactored general imports and preprocessing * Refactored visualization * Refactored analysis * Black formatting and import optimisation * Next try on black formatting * Fixed typo in pyproject.toml * Updated pyproject.toml to include submodules in installation * Updated README.md
1 parent 4221dce commit 2c3c90c

24 files changed

+252
-94
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Its main features are:
2626

2727
- Generate a new python environment using [anaconda](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
2828
or [pip](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/).
29-
- Install required Python packages (see [pyproject.toml](pyproject.toml)) in the environment
3029
- Download or clone autoprot
3130
- If you clone the repository, make sure to include the dependencies as submodules (example below)
3231

@@ -40,7 +39,23 @@ git clone --recurse-submodules https://github.com/ag-warscheid/autoprot.git
4039
git submodule update --init --recursive
4140
```
4241

43-
- Next you need to install R. Please follow the instructions at the [R manual](https://cran.r-project.org/index.html) and install R to a custom location
42+
- Install autoprot to your Python env using
43+
44+
```
45+
cd autoprot
46+
pip install .
47+
```
48+
- Next you need to install R. Please follow the instructions from the [R manual](https://cran.r-project.org/index.html) and install R to a custom location
49+
- On Linux you could typically do
50+
51+
```bash
52+
wget https://cran.r-project.org/src/base/R-4/R-4.5.3.tar.gz
53+
tar -xzf R-4.5.3.tar.gz
54+
cd R-4.5.3
55+
./configure
56+
make
57+
```
58+
4459
- Start autoprot by importing it from any Python console you like. It will generate an autoprot.conf file in the autoprot package directory that you need to edit.
4560
- Insert the path to your Rscript executable that you just installed as value for the R variable
4661
- The RFunctions variable should point the RFunctions.R file from autoprot.

autoprot/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import sys
2+
23
from . import common
4+
from . import decorators
5+
from . import r_helper
36

47
__version__ = "dev"
58
__author__ = "The autoprot contributors"
@@ -9,6 +12,7 @@
912
module_pointer = sys.modules[__name__]
1013
# we can explicitly make assignments on it
1114
module_pointer.check_r_install = False
12-
1315
# write the environment.txt file
1416
common.generate_environment_txt()
17+
18+
from . import preprocessing

autoprot/analysis/PCA.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99

1010
from typing import Union, Literal
1111

12-
import pandas as pd
13-
import numpy as np
1412
import matplotlib.pylab as plt
13+
import numpy as np
14+
import pandas as pd
1515
import seaborn as sns
16-
16+
from gprofiler import GProfiler
1717
from sklearn.decomposition import PCA
18-
from .. import r_helper
1918

20-
from gprofiler import GProfiler
19+
from autoprot import r_helper
2120

2221
gp = GProfiler(user_agent="autoprot", return_dataframe=True)
2322
RFUNCTIONS, R = r_helper.return_r_path()
2423

2524
# check where this is actually used and make it local
2625
cmap = sns.diverging_palette(150, 275, s=80, l=55, n=9)
2726

27+
__all__ = ["AutoPCA"]
28+
2829

2930
class AutoPCA:
3031
# noinspection PyUnresolvedReferences

autoprot/analysis/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
from .PCA import *
12
from .clustering import *
23
from .functional import *
3-
from .PCA import *
44
from .qc import *
55
from .stat_test import *
66
from .stats import *
7+
8+
# Optional: define what's exported when someone does `from analysis import *`
9+
__all__ = [
10+
"clustering",
11+
"functional",
12+
"PCA",
13+
"qc",
14+
"stat_test",
15+
"stats",
16+
]

autoprot/analysis/clustering.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
import matplotlib.pylab as plt
1717
import numpy as np
1818
import pandas as pd
19-
from pandas.api.types import is_numeric_dtype
2019
import seaborn as sns
2120
from gprofiler import GProfiler
2221
from numpy.typing import ArrayLike
22+
from pandas.api.types import is_numeric_dtype
2323
from scipy import cluster as clst
2424
from scipy.spatial import distance
2525
from scipy.stats import zscore
@@ -30,14 +30,16 @@
3030
davies_bouldin_score,
3131
)
3232

33-
from .. import r_helper
33+
from autoprot import r_helper
3434

3535
gp = GProfiler(user_agent="autoprot", return_dataframe=True)
3636
RFUNCTIONS, R = r_helper.return_r_path()
3737

3838
# check where this is actually used and make it local
3939
cmap = sns.diverging_palette(150, 275, s=80, l=55, n=9)
4040

41+
__all__ = ["HCA", "KMeans"]
42+
4143

4244
class _Cluster:
4345
r"""

autoprot/analysis/functional.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,23 @@
1111
from importlib import resources
1212
from typing import Union, Literal, List, Dict, Any, Tuple
1313

14-
import pandas as pd
15-
import numpy as np
1614
import matplotlib.pylab as plt
15+
import numpy as np
16+
import pandas as pd
1717
import seaborn as sns
18-
19-
from .. import visualization as vis
20-
from .. import r_helper
21-
2218
from gprofiler import GProfiler
2319

20+
from autoprot import r_helper
21+
from autoprot import visualization as vis
22+
2423
gp = GProfiler(user_agent="autoprot", return_dataframe=True)
2524
RFUNCTIONS, R = r_helper.return_r_path()
2625

2726
# check where this is actually used and make it local
2827
cmap = sns.diverging_palette(150, 275, s=80, l=55, n=9)
2928

29+
__all__ = ["go_analysis", "KSEA"]
30+
3031

3132
def go_analysis(
3233
gene_list: list[str],

autoprot/analysis/qc.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,34 @@
77
@documentation: Julian
88
"""
99

10-
from typing import Literal
1110
from datetime import date
11+
from operator import itemgetter
12+
from typing import Literal
1213

13-
import pandas as pd
14-
import numpy as np
1514
import matplotlib.pylab as plt
16-
import seaborn as sns
17-
from operator import itemgetter
1815
import missingno as msn
19-
20-
from .. import r_helper
21-
16+
import numpy as np
17+
import pandas as pd
18+
import seaborn as sns
2219
from gprofiler import GProfiler
2320

21+
from autoprot import r_helper
22+
2423
gp = GProfiler(user_agent="autoprot", return_dataframe=True)
2524
RFUNCTIONS, R = r_helper.return_r_path()
2625

2726
# check where this is actually used and make it local
2827
cmap = sns.diverging_palette(150, 275, s=80, l=55, n=9)
2928

29+
__all__ = [
30+
"miss_analysis",
31+
"missed_cleavages",
32+
"enrichment_specificity",
33+
"SILAC_labeling_efficiency",
34+
"dimethyl_labeling_efficieny",
35+
"tmt6plex_labeling_efficiency",
36+
]
37+
3038

3139
def miss_analysis(
3240
df,

autoprot/analysis/stat_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717
from scipy.stats import ttest_1samp, ttest_ind
1818
from statsmodels.stats import multitest as mt
1919

20-
from .. import preprocessing as pp
21-
from .. import r_helper
20+
from autoprot import preprocessing as pp
21+
from autoprot import r_helper
2222

2323
gp = GProfiler(user_agent="autoprot", return_dataframe=True)
2424
RFUNCTIONS, R = r_helper.return_r_path()
2525

2626
# check where this is actually used and make it local
2727
cmap = sns.diverging_palette(150, 275, s=80, l=55, n=9)
2828

29+
__all__ = ["ttest", "adjust_p", "cohen_d", "limma", "rank_prod"]
30+
2931

3032
def ttest(
3133
df,

autoprot/analysis/stats.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
@documentation: Julian
88
"""
99

10-
import pandas as pd
11-
import numpy as np
1210
import matplotlib.pylab as plt
11+
import numpy as np
12+
import pandas as pd
1313
import seaborn as sns
14-
15-
from .. import r_helper
16-
1714
from gprofiler import GProfiler
1815

16+
from autoprot import r_helper
17+
1918
gp = GProfiler(user_agent="autoprot", return_dataframe=True)
2019
RFUNCTIONS, R = r_helper.return_r_path()
2120

2221
# check where this is actually used and make it local
2322
cmap = sns.diverging_palette(150, 275, s=80, l=55, n=9)
2423

24+
__all__ = ["edm", "loess", "make_psm"]
25+
2526

2627
def edm(matrix_a, matrix_b):
2728
"""

autoprot/data/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)