pertpy 0.6.0__py3-none-any.whl → 0.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pertpy/__init__.py +4 -2
 - pertpy/data/__init__.py +66 -1
 - pertpy/data/_dataloader.py +28 -26
 - pertpy/data/_datasets.py +261 -92
 - pertpy/metadata/__init__.py +6 -0
 - pertpy/metadata/_cell_line.py +795 -0
 - pertpy/metadata/_compound.py +128 -0
 - pertpy/metadata/_drug.py +238 -0
 - pertpy/metadata/_look_up.py +569 -0
 - pertpy/metadata/_metadata.py +70 -0
 - pertpy/metadata/_moa.py +125 -0
 - pertpy/plot/__init__.py +0 -13
 - pertpy/preprocessing/__init__.py +2 -0
 - pertpy/preprocessing/_guide_rna.py +89 -6
 - pertpy/tools/__init__.py +48 -15
 - pertpy/tools/_augur.py +329 -32
 - pertpy/tools/_cinemaot.py +145 -6
 - pertpy/tools/_coda/_base_coda.py +1237 -116
 - pertpy/tools/_coda/_sccoda.py +66 -36
 - pertpy/tools/_coda/_tasccoda.py +46 -39
 - pertpy/tools/_dialogue.py +180 -77
 - pertpy/tools/_differential_gene_expression/__init__.py +20 -0
 - pertpy/tools/_differential_gene_expression/_base.py +657 -0
 - pertpy/tools/_differential_gene_expression/_checks.py +41 -0
 - pertpy/tools/_differential_gene_expression/_dge_comparison.py +86 -0
 - pertpy/tools/_differential_gene_expression/_edger.py +125 -0
 - pertpy/tools/_differential_gene_expression/_formulaic.py +189 -0
 - pertpy/tools/_differential_gene_expression/_pydeseq2.py +95 -0
 - pertpy/tools/_differential_gene_expression/_simple_tests.py +162 -0
 - pertpy/tools/_differential_gene_expression/_statsmodels.py +72 -0
 - pertpy/tools/_distances/_distance_tests.py +29 -24
 - pertpy/tools/_distances/_distances.py +584 -98
 - pertpy/tools/_enrichment.py +460 -0
 - pertpy/tools/_kernel_pca.py +1 -1
 - pertpy/tools/_milo.py +406 -49
 - pertpy/tools/_mixscape.py +677 -55
 - pertpy/tools/_perturbation_space/_clustering.py +10 -3
 - pertpy/tools/_perturbation_space/_comparison.py +112 -0
 - pertpy/tools/_perturbation_space/_discriminator_classifiers.py +524 -0
 - pertpy/tools/_perturbation_space/_perturbation_space.py +146 -52
 - pertpy/tools/_perturbation_space/_simple.py +52 -11
 - pertpy/tools/_scgen/__init__.py +1 -1
 - pertpy/tools/_scgen/_base_components.py +2 -3
 - pertpy/tools/_scgen/_scgen.py +706 -0
 - pertpy/tools/_scgen/_utils.py +3 -5
 - pertpy/tools/decoupler_LICENSE +674 -0
 - {pertpy-0.6.0.dist-info → pertpy-0.8.0.dist-info}/METADATA +48 -20
 - pertpy-0.8.0.dist-info/RECORD +57 -0
 - {pertpy-0.6.0.dist-info → pertpy-0.8.0.dist-info}/WHEEL +1 -1
 - pertpy/plot/_augur.py +0 -234
 - pertpy/plot/_cinemaot.py +0 -81
 - pertpy/plot/_coda.py +0 -1001
 - pertpy/plot/_dialogue.py +0 -91
 - pertpy/plot/_guide_rna.py +0 -82
 - pertpy/plot/_milopy.py +0 -284
 - pertpy/plot/_mixscape.py +0 -594
 - pertpy/plot/_scgen.py +0 -337
 - pertpy/tools/_differential_gene_expression.py +0 -99
 - pertpy/tools/_metadata/__init__.py +0 -0
 - pertpy/tools/_metadata/_cell_line.py +0 -613
 - pertpy/tools/_metadata/_look_up.py +0 -342
 - pertpy/tools/_perturbation_space/_discriminator_classifier.py +0 -381
 - pertpy/tools/_scgen/_jax_scgen.py +0 -370
 - pertpy-0.6.0.dist-info/RECORD +0 -50
 - /pertpy/tools/_scgen/{_jax_scgenvae.py → _scgenvae.py} +0 -0
 - {pertpy-0.6.0.dist-info → pertpy-0.8.0.dist-info}/licenses/LICENSE +0 -0
 
    
        pertpy/__init__.py
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            __author__ = "Lukas Heumos"
         
     | 
| 
       4 
4 
     | 
    
         
             
            __email__ = "lukas.heumos@posteo.net"
         
     | 
| 
       5 
     | 
    
         
            -
            __version__ = "0. 
     | 
| 
      
 5 
     | 
    
         
            +
            __version__ = "0.8.0"
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            import warnings
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
         @@ -11,9 +11,11 @@ from numba import NumbaDeprecationWarning 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            warnings.filterwarnings("ignore", category=NumbaDeprecationWarning)
         
     | 
| 
       13 
13 
     | 
    
         
             
            warnings.filterwarnings("ignore", category=MatplotlibDeprecationWarning)
         
     | 
| 
       14 
     | 
    
         
            -
            warnings.filterwarnings("ignore", category= 
     | 
| 
      
 14 
     | 
    
         
            +
            warnings.filterwarnings("ignore", category=SyntaxWarning)
         
     | 
| 
      
 15 
     | 
    
         
            +
            warnings.filterwarnings("ignore", category=UserWarning, module="scvi._settings")
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
            from . import data as dt
         
     | 
| 
      
 18 
     | 
    
         
            +
            from . import metadata as md
         
     | 
| 
       17 
19 
     | 
    
         
             
            from . import plot as pl
         
     | 
| 
       18 
20 
     | 
    
         
             
            from . import preprocessing as pp
         
     | 
| 
       19 
21 
     | 
    
         
             
            from . import tools as tl
         
     | 
    
        pertpy/data/__init__.py
    CHANGED
    
    | 
         @@ -7,12 +7,14 @@ from pertpy.data._datasets import ( 
     | 
|
| 
       7 
7 
     | 
    
         
             
                burczynski_crohn,
         
     | 
| 
       8 
8 
     | 
    
         
             
                chang_2021,
         
     | 
| 
       9 
9 
     | 
    
         
             
                cinemaot_example,
         
     | 
| 
      
 10 
     | 
    
         
            +
                combosciplex,
         
     | 
| 
       10 
11 
     | 
    
         
             
                datlinger_2017,
         
     | 
| 
       11 
12 
     | 
    
         
             
                datlinger_2021,
         
     | 
| 
       12 
13 
     | 
    
         
             
                dialogue_example,
         
     | 
| 
       13 
14 
     | 
    
         
             
                distance_example,
         
     | 
| 
       14 
15 
     | 
    
         
             
                dixit_2016,
         
     | 
| 
       15 
16 
     | 
    
         
             
                dixit_2016_raw,
         
     | 
| 
      
 17 
     | 
    
         
            +
                dong_2023,
         
     | 
| 
       16 
18 
     | 
    
         
             
                frangieh_2021,
         
     | 
| 
       17 
19 
     | 
    
         
             
                frangieh_2021_protein,
         
     | 
| 
       18 
20 
     | 
    
         
             
                frangieh_2021_raw,
         
     | 
| 
         @@ -22,6 +24,7 @@ from pertpy.data._datasets import ( 
     | 
|
| 
       22 
24 
     | 
    
         
             
                gasperini_2019_lowmoi,
         
     | 
| 
       23 
25 
     | 
    
         
             
                gehring_2019,
         
     | 
| 
       24 
26 
     | 
    
         
             
                haber_2017_regions,
         
     | 
| 
      
 27 
     | 
    
         
            +
                hagai_2018,
         
     | 
| 
       25 
28 
     | 
    
         
             
                kang_2018,
         
     | 
| 
       26 
29 
     | 
    
         
             
                mcfarland_2020,
         
     | 
| 
       27 
30 
     | 
    
         
             
                norman_2019,
         
     | 
| 
         @@ -36,17 +39,79 @@ from pertpy.data._datasets import ( 
     | 
|
| 
       36 
39 
     | 
    
         
             
                schraivogel_2020_tap_screen_chr8,
         
     | 
| 
       37 
40 
     | 
    
         
             
                schraivogel_2020_tap_screen_chr11,
         
     | 
| 
       38 
41 
     | 
    
         
             
                sciplex3_raw,
         
     | 
| 
      
 42 
     | 
    
         
            +
                sciplex_gxe1,
         
     | 
| 
       39 
43 
     | 
    
         
             
                shifrut_2018,
         
     | 
| 
       40 
     | 
    
         
            -
                 
     | 
| 
      
 44 
     | 
    
         
            +
                smillie_2019,
         
     | 
| 
       41 
45 
     | 
    
         
             
                srivatsan_2020_sciplex2,
         
     | 
| 
       42 
46 
     | 
    
         
             
                srivatsan_2020_sciplex3,
         
     | 
| 
       43 
47 
     | 
    
         
             
                srivatsan_2020_sciplex4,
         
     | 
| 
       44 
48 
     | 
    
         
             
                stephenson_2021_subsampled,
         
     | 
| 
      
 49 
     | 
    
         
            +
                tasccoda_example,
         
     | 
| 
       45 
50 
     | 
    
         
             
                tian_2019_day7neuron,
         
     | 
| 
       46 
51 
     | 
    
         
             
                tian_2019_ipsc,
         
     | 
| 
       47 
52 
     | 
    
         
             
                tian_2021_crispra,
         
     | 
| 
       48 
53 
     | 
    
         
             
                tian_2021_crispri,
         
     | 
| 
       49 
54 
     | 
    
         
             
                weinreb_2020,
         
     | 
| 
       50 
55 
     | 
    
         
             
                xie_2017,
         
     | 
| 
      
 56 
     | 
    
         
            +
                zhang_2021,
         
     | 
| 
       51 
57 
     | 
    
         
             
                zhao_2021,
         
     | 
| 
       52 
58 
     | 
    
         
             
            )
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            __all__ = [
         
     | 
| 
      
 61 
     | 
    
         
            +
                "adamson_2016_pilot",
         
     | 
| 
      
 62 
     | 
    
         
            +
                "adamson_2016_upr_epistasis",
         
     | 
| 
      
 63 
     | 
    
         
            +
                "adamson_2016_upr_perturb_seq",
         
     | 
| 
      
 64 
     | 
    
         
            +
                "aissa_2021",
         
     | 
| 
      
 65 
     | 
    
         
            +
                "bhattacherjee",
         
     | 
| 
      
 66 
     | 
    
         
            +
                "burczynski_crohn",
         
     | 
| 
      
 67 
     | 
    
         
            +
                "chang_2021",
         
     | 
| 
      
 68 
     | 
    
         
            +
                "cinemaot_example",
         
     | 
| 
      
 69 
     | 
    
         
            +
                "combosciplex",
         
     | 
| 
      
 70 
     | 
    
         
            +
                "datlinger_2017",
         
     | 
| 
      
 71 
     | 
    
         
            +
                "datlinger_2021",
         
     | 
| 
      
 72 
     | 
    
         
            +
                "dialogue_example",
         
     | 
| 
      
 73 
     | 
    
         
            +
                "distance_example",
         
     | 
| 
      
 74 
     | 
    
         
            +
                "dixit_2016",
         
     | 
| 
      
 75 
     | 
    
         
            +
                "dixit_2016_raw",
         
     | 
| 
      
 76 
     | 
    
         
            +
                "dong_2023",
         
     | 
| 
      
 77 
     | 
    
         
            +
                "frangieh_2021",
         
     | 
| 
      
 78 
     | 
    
         
            +
                "frangieh_2021_protein",
         
     | 
| 
      
 79 
     | 
    
         
            +
                "frangieh_2021_raw",
         
     | 
| 
      
 80 
     | 
    
         
            +
                "frangieh_2021_rna",
         
     | 
| 
      
 81 
     | 
    
         
            +
                "gasperini_2019_atscale",
         
     | 
| 
      
 82 
     | 
    
         
            +
                "gasperini_2019_highmoi",
         
     | 
| 
      
 83 
     | 
    
         
            +
                "gasperini_2019_lowmoi",
         
     | 
| 
      
 84 
     | 
    
         
            +
                "gehring_2019",
         
     | 
| 
      
 85 
     | 
    
         
            +
                "haber_2017_regions",
         
     | 
| 
      
 86 
     | 
    
         
            +
                "hagai_2018",
         
     | 
| 
      
 87 
     | 
    
         
            +
                "kang_2018",
         
     | 
| 
      
 88 
     | 
    
         
            +
                "mcfarland_2020",
         
     | 
| 
      
 89 
     | 
    
         
            +
                "norman_2019",
         
     | 
| 
      
 90 
     | 
    
         
            +
                "norman_2019_raw",
         
     | 
| 
      
 91 
     | 
    
         
            +
                "papalexi_2021",
         
     | 
| 
      
 92 
     | 
    
         
            +
                "replogle_2022_k562_essential",
         
     | 
| 
      
 93 
     | 
    
         
            +
                "replogle_2022_k562_gwps",
         
     | 
| 
      
 94 
     | 
    
         
            +
                "replogle_2022_rpe1",
         
     | 
| 
      
 95 
     | 
    
         
            +
                "sc_sim_augur",
         
     | 
| 
      
 96 
     | 
    
         
            +
                "schiebinger_2019_16day",
         
     | 
| 
      
 97 
     | 
    
         
            +
                "schiebinger_2019_18day",
         
     | 
| 
      
 98 
     | 
    
         
            +
                "schraivogel_2020_tap_screen_chr8",
         
     | 
| 
      
 99 
     | 
    
         
            +
                "schraivogel_2020_tap_screen_chr11",
         
     | 
| 
      
 100 
     | 
    
         
            +
                "sciplex3_raw",
         
     | 
| 
      
 101 
     | 
    
         
            +
                "sciplex_gxe1",
         
     | 
| 
      
 102 
     | 
    
         
            +
                "shifrut_2018",
         
     | 
| 
      
 103 
     | 
    
         
            +
                "smillie_2019",
         
     | 
| 
      
 104 
     | 
    
         
            +
                "srivatsan_2020_sciplex2",
         
     | 
| 
      
 105 
     | 
    
         
            +
                "srivatsan_2020_sciplex3",
         
     | 
| 
      
 106 
     | 
    
         
            +
                "srivatsan_2020_sciplex4",
         
     | 
| 
      
 107 
     | 
    
         
            +
                "stephenson_2021_subsampled",
         
     | 
| 
      
 108 
     | 
    
         
            +
                "tasccoda_example",
         
     | 
| 
      
 109 
     | 
    
         
            +
                "tian_2019_day7neuron",
         
     | 
| 
      
 110 
     | 
    
         
            +
                "tian_2019_ipsc",
         
     | 
| 
      
 111 
     | 
    
         
            +
                "tian_2021_crispra",
         
     | 
| 
      
 112 
     | 
    
         
            +
                "tian_2021_crispri",
         
     | 
| 
      
 113 
     | 
    
         
            +
                "weinreb_2020",
         
     | 
| 
      
 114 
     | 
    
         
            +
                "xie_2017",
         
     | 
| 
      
 115 
     | 
    
         
            +
                "zhao_2021",
         
     | 
| 
      
 116 
     | 
    
         
            +
                "zhang_2021",
         
     | 
| 
      
 117 
     | 
    
         
            +
            ]
         
     | 
    
        pertpy/data/_dataloader.py
    CHANGED
    
    | 
         @@ -2,18 +2,18 @@ import tempfile 
     | 
|
| 
       2 
2 
     | 
    
         
             
            from pathlib import Path
         
     | 
| 
       3 
3 
     | 
    
         
             
            from random import choice
         
     | 
| 
       4 
4 
     | 
    
         
             
            from string import ascii_lowercase
         
     | 
| 
       5 
     | 
    
         
            -
            from typing import Union
         
     | 
| 
       6 
5 
     | 
    
         
             
            from zipfile import ZipFile
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
7 
     | 
    
         
             
            import requests
         
     | 
| 
       9 
     | 
    
         
            -
            from  
     | 
| 
      
 8 
     | 
    
         
            +
            from filelock import FileLock
         
     | 
| 
      
 9 
     | 
    
         
            +
            from lamin_utils import logger
         
     | 
| 
       10 
10 
     | 
    
         
             
            from rich.progress import Progress
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
            def _download(  # pragma: no cover
         
     | 
| 
       14 
14 
     | 
    
         
             
                url: str,
         
     | 
| 
       15 
15 
     | 
    
         
             
                output_file_name: str = None,
         
     | 
| 
       16 
     | 
    
         
            -
                output_path:  
     | 
| 
      
 16 
     | 
    
         
            +
                output_path: str | Path = None,
         
     | 
| 
       17 
17 
     | 
    
         
             
                block_size: int = 1024,
         
     | 
| 
       18 
18 
     | 
    
         
             
                overwrite: bool = False,
         
     | 
| 
       19 
19 
     | 
    
         
             
                is_zip: bool = False,
         
     | 
| 
         @@ -38,31 +38,33 @@ def _download(  # pragma: no cover 
     | 
|
| 
       38 
38 
     | 
    
         
             
                download_to_path = (
         
     | 
| 
       39 
39 
     | 
    
         
             
                    f"{output_path}{output_file_name}" if str(output_path).endswith("/") else f"{output_path}/{output_file_name}"
         
     | 
| 
       40 
40 
     | 
    
         
             
                )
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                Path(output_path).mkdir(parents=True, exist_ok=True)
         
     | 
| 
      
 43 
     | 
    
         
            +
                lock_path = f"{output_path}/{output_file_name}.lock"
         
     | 
| 
      
 44 
     | 
    
         
            +
                with FileLock(lock_path):
         
     | 
| 
      
 45 
     | 
    
         
            +
                    if Path(download_to_path).exists() and not overwrite:
         
     | 
| 
      
 46 
     | 
    
         
            +
                        logger.warning(f"File {download_to_path} already exists!")
         
     | 
| 
       45 
47 
     | 
    
         
             
                        return
         
     | 
| 
       46 
     | 
    
         
            -
                    else:
         
     | 
| 
       47 
     | 
    
         
            -
                        print(f"{warning} Overwriting...")
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
                    temp_file_name = f"{download_to_path}.part"
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                    response = requests.get(url, stream=True)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    total = int(response.headers.get("content-length", 0))
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    with Progress(refresh_per_second=100) as progress:
         
     | 
| 
      
 55 
     | 
    
         
            +
                        task = progress.add_task("[red]Downloading...", total=total)
         
     | 
| 
      
 56 
     | 
    
         
            +
                        with Path(temp_file_name).open("wb") as file:
         
     | 
| 
      
 57 
     | 
    
         
            +
                            for data in response.iter_content(block_size):
         
     | 
| 
      
 58 
     | 
    
         
            +
                                file.write(data)
         
     | 
| 
      
 59 
     | 
    
         
            +
                                progress.update(task, advance=block_size)
         
     | 
| 
      
 60 
     | 
    
         
            +
                        progress.update(task, completed=total, refresh=True)
         
     | 
| 
       51 
61 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                    task = progress.add_task("[red]Downloading...", total=total)
         
     | 
| 
       54 
     | 
    
         
            -
                    Path(output_path).mkdir(parents=True, exist_ok=True)
         
     | 
| 
       55 
     | 
    
         
            -
                    with Path(download_to_path).open("wb") as file:
         
     | 
| 
       56 
     | 
    
         
            -
                        for data in response.iter_content(block_size):
         
     | 
| 
       57 
     | 
    
         
            -
                            file.write(data)
         
     | 
| 
       58 
     | 
    
         
            -
                            progress.update(task, advance=block_size)
         
     | 
| 
      
 62 
     | 
    
         
            +
                    Path(temp_file_name).replace(download_to_path)
         
     | 
| 
       59 
63 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                     
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
                    if is_zip:
         
     | 
| 
      
 65 
     | 
    
         
            +
                        output_path = output_path or tempfile.gettempdir()
         
     | 
| 
      
 66 
     | 
    
         
            +
                        with ZipFile(download_to_path, "r") as zip_obj:
         
     | 
| 
      
 67 
     | 
    
         
            +
                            zip_obj.extractall(path=output_path)
         
     | 
| 
      
 68 
     | 
    
         
            +
                            zip_obj.namelist()
         
     | 
| 
       62 
69 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
                 
     | 
| 
       64 
     | 
    
         
            -
                    output_path = output_path or tempfile.gettempdir()
         
     | 
| 
       65 
     | 
    
         
            -
                    with ZipFile(download_to_path, "r") as zip_obj:
         
     | 
| 
       66 
     | 
    
         
            -
                        zip_obj.extractall(path=output_path)
         
     | 
| 
       67 
     | 
    
         
            -
                        extracted = zip_obj.namelist()
         
     | 
| 
       68 
     | 
    
         
            -
                        print(extracted)
         
     | 
| 
      
 70 
     | 
    
         
            +
                Path(lock_path).unlink()
         
     |