ScreenPro2 0.5.0__tar.gz

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.
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-2024 ScreenPro2 Development Team.
4
+ All rights reserved.
5
+ Gilbart Lab, UCSF / Arc Institute.
6
+ Multi-Omics Tech Center, Arc Insititue.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+
@@ -0,0 +1,366 @@
1
+ Metadata-Version: 2.3
2
+ Name: ScreenPro2
3
+ Version: 0.5.0
4
+ Summary: Flexible analysis of high-content CRISPR screening
5
+ License: MIT
6
+ Keywords: CRISPR,screening,bioinformatics
7
+ Author: Abe Arab
8
+ Author-email: abea@arcinstitute.org
9
+ Requires-Python: >=3.9
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Project-URL: Homepage, https://github.com/ArcInstitute/ScreenPro2
18
+ Project-URL: Repository, https://github.com/ArcInstitute/ScreenPro2
19
+ Description-Content-Type: text/markdown
20
+
21
+ [![website](https://img.shields.io/badge/website-live-brightgreen)](https://arcinstitute.org/tools/screenpro2)
22
+ [![PyPI version](https://badge.fury.io/py/ScreenPro2.svg)](https://badge.fury.io/py/ScreenPro2)
23
+ [![Documentation Status](https://readthedocs.org/projects/screenpro2/badge/?version=latest)](https://screenpro2.readthedocs.io/en/latest/?version=latest)
24
+ [![Downloads](https://static.pepy.tech/badge/screenpro2)](https://pepy.tech/project/screenpro2)
25
+ [![Downloads](https://static.pepy.tech/badge/screenpro2/month)](https://pepy.tech/project/screenpro2)
26
+ [![CodeQL](https://github.com/ArcInstitute/ScreenPro2/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/ArcInstitute/ScreenPro2/actions/workflows/github-code-scanning/codeql)
27
+ # ScreenPro2
28
+
29
+ ## Introduction
30
+
31
+ ### TL;DR
32
+
33
+ [**ReadTheDocs**](https://screenpro2.readthedocs.io) |
34
+ [**PyPI**](https://pypi.org/project/ScreenPro2)
35
+
36
+ ScreenPro2 enables perform flexible analysis on high-content CRISPR screening datasets. It has functionalities to process data from diverse CRISPR screen platforms and is designed to be modular to enable easy extension to custom CRISPR screen platforms or other commonly used platforms in addition to the ones currently implemented.
37
+
38
+ ___
39
+ <details>
40
+ <summary>Background</summary>
41
+ <br>
42
+
43
+ Functional genomics field is evolving rapidly and many more CRISPR screen platforms are now developed. Therefore,
44
+ it's important to have a standardized workflow to analyze the data from these screens. ScreenPro2 is provided to
45
+ enable researchers to easily process and analyze data from CRISPR screens. Currently, you need to have a basic background in programming (especially Python) to use ScreenPro2.
46
+
47
+ ScreenPro2 is conceptually similar to the [**ScreenProcessing**](https://github.com/mhorlbeck/ScreenProcessing) pipeline but **ScreenPro2** is designed to be more modular, flexible, and extensible. Common CRISPR screen methods that we have implemented here are illustrated in a recent review paper:
48
+
49
+ > From: [A new era in functional genomics screens](https://www.nature.com/articles/s41576-021-00409-w)
50
+
51
+ > Fig. 1: Common types of CRISPR screening modalities indicating advances in CRISPR methods.
52
+
53
+ > <img width="1000" alt="image" src="https://github.com/GilbertLabUCSF/ScreenPro2/assets/53412130/a39400ad-b24f-4859-b6e7-b4d5f269119c">
54
+
55
+ </details>
56
+
57
+ ___
58
+
59
+ ## Installation
60
+ ScreenPro2 is available on [PyPI](https://pypi.org/project/ScreenPro2/) and can be installed with pip:
61
+ ```bash
62
+ pip install ScreenPro2
63
+ ```
64
+ ___
65
+ For the latest version (development version) install from GitHub:
66
+ ```bash
67
+ pip install git+https://github.com/ArcInstitute/ScreenPro2.git
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ ### Command Line Interface (CLI)
73
+ ScreenPro2 has a built-in command line interface (CLI). You can access the CLI by running the following command in your terminal:
74
+
75
+ ```bash
76
+ screenpro --help
77
+ ```
78
+
79
+ ### Python Package Usage
80
+ You can also use ScreenPro2 as a Python package. To use ScreenPro2 in your Python code, you can import it as follows:
81
+
82
+ ```python
83
+ import screenpro as scp
84
+ ```
85
+
86
+ ## Analysis Workflow
87
+
88
+ Data analysis for CRISPR screens with NGS readouts can be broken down into three main steps:
89
+
90
+ - [Step 1: FASTQ processing](#step-1-fastq-processing)
91
+ - [Step 2: Phenotype calculation](#step-2-phenotype-calculation)
92
+ - [Step 3: Data visualization](#step-3-data-visualization)
93
+
94
+ ### Step 1: FASTQ processing
95
+
96
+ The first step in analyzing CRISPR screens with deep sequencing readouts is to process the FASTQ files and generate counts for each guide RNA element in the library. ScreenPro2 has built-in functionalities to process FASTQ files and generate counts for different types of CRISPR screens platforms (see [Supported CRISPR Screen Platforms](#supported-crispr-screen-platforms)).
97
+
98
+ <details>
99
+ <summary>Command Line Interface (CLI)</summary>
100
+ <br>
101
+ ScreenPro2 has a built-in command line interface (CLI) to process FASTQ files and generate counts.
102
+
103
+ ```bash
104
+ screenpro guidecounter --help
105
+ ```
106
+
107
+ A draft code to process FASTQ files and generate counts for [CRISPRa/i-single-sgRNA-screens](#dcas9-crisprai-single-sgrna-screens) dataset:
108
+
109
+ ```bash
110
+ screenpro guidecounter
111
+ --cas-type dCas9
112
+ --single-guide-design
113
+ -l <path-to-CRISPR-library-table>
114
+ -p <path-to-fastq-directory>
115
+ -s <sample-id-1>,<sample2-id> # comma-separated list of sample ids, i.e. `<sample_id>.fastq.gz` for single sgRNA screens
116
+ -o <output-directory>
117
+ --write-count-matrix
118
+ ```
119
+
120
+ A draft code to process FASTQ files and generate counts for [CRISPRa/i-dual-sgRNA-screens](#dcas9-crisprai-dual-sgrna-screens) dataset:
121
+
122
+ ```bash
123
+ screenpro guidecounter
124
+ --cas-type dCas9
125
+ --dual-guide-design
126
+ -l <path-to-CRISPR-library-table>
127
+ -p <path-to-fastq-directory>
128
+ -s <sample-id-1>,<sample2-id> # comma-separated list of sample ids, i.e. `<sample_id>_R[1,2].fastq.gz` for dual sgRNA screens
129
+ -o <output-directory>
130
+ --write-count-matrix
131
+ ```
132
+ ___
133
+
134
+ </details>
135
+
136
+ <details>
137
+ <summary>Python Package Usage</summary>
138
+ <br>
139
+
140
+ In addition to the CLI, ScreenPro2 has a built-in method to process FASTQ files and generate counts in Python.
141
+
142
+ This method is implemented in the `ngs` module and relvent submodules.
143
+ A minor novelty here has enabled processing single, dual, or multiple sgRNA
144
+ CRISPR screens. Also, this approach can retain recombination events which can
145
+ occur in dual or higher order sgRNA CRISPR screens.
146
+
147
+ Currently, `GuideCounter` class from the `ngs` module can process FASTQ files and generate counts for standard
148
+ CRISPR screens with [single](#dcas9-crisprai-single-sgrna-screens) or [dual](#dcas9-crisprai-dual-sgrna-screens)
149
+ guide design.
150
+
151
+ Here is a draft code to process FASTQ files and generate counts for an experiment with [CRISPRa/i-dual-sgRNA-screens](#dcas9-crisprai-dual-sgrna-screens):
152
+
153
+ ```python
154
+ # Initialize the GuideCounter object
155
+ counter = scp.GuideCounter(cas_type = 'cas9', library_type = 'single_guide_design')
156
+
157
+ # Load the reference library
158
+ counter.load_library("<path-to-CRISPR-library-table>", sep = '\t', verbose = True, index_col=None)
159
+
160
+ # Define the samples
161
+ samples = []
162
+ ## `samples` is a list of sample ids in the experiment.
163
+ ## Each sample id should match the sample name in the FASTQ files, i.e. <sample_id>.fastq.gz
164
+
165
+ # Process the FASTQ files and generate counts
166
+ counter.get_counts_matrix(
167
+ fastq_dir = '<path-to-fastq-directory>',
168
+ samples = samples,
169
+ verbose = True
170
+ )
171
+ ```
172
+
173
+ Here is a draft code to process FASTQ files and generate counts for an experiment with [CRISPRa/i-dual-sgRNA-screens](#crispri-dual-sgrna-screens):
174
+
175
+
176
+ ```python
177
+ # Initialize the Counter object
178
+ counter = scp.GuideCounter(cas_type = 'dCas9', library_type = 'dual_guide_design')
179
+
180
+ # Load the reference library
181
+ counter.load_library("<path-to-CRISPR-library-table>", sep = '\t', verbose = True, index_col=None)
182
+
183
+ # Define the samples
184
+ samples = []
185
+ ## `samples` is a list of sample ids in the experiment.
186
+ ## Each sample id should match the sample name in the FASTQ files, i.e. <sample_id>_R[1,2].fastq.gz
187
+
188
+ # Process the FASTQ files and generate counts
189
+ counter.get_counts_matrix(
190
+ fastq_dir = '<path-to-fastq-directory>',
191
+ samples = samples,
192
+ verbose = True
193
+ )
194
+ ```
195
+
196
+ After this, you have `.counts_mat` calculated in the `GuideCounter` object.
197
+
198
+ To proceed, you need to create an `AnnData` object from the counts matrix and metadata. You can use the following code to create an `AnnData` object:
199
+
200
+ ```python
201
+ adata = counter.build_counts_anndata()
202
+ ```
203
+
204
+ ___
205
+
206
+ </details>
207
+
208
+ <br>
209
+
210
+ ### Step 2: Phenotype calculation
211
+
212
+ Once you have the counts, you can use ScreenPro2 `phenoscore` and `phenostats` modules to calculate the phenotype scores and statistics between screen arms.
213
+
214
+ <details>
215
+ <summary>Load Data</summary>
216
+ <br>
217
+
218
+ First, load your data into an `AnnData` object (see [anndata](https://anndata.readthedocs.io/en/latest/index.html) for more information).
219
+
220
+ The `AnnData` object must have the following contents:
221
+ - `adata.X` – counts matrix (samples x targets) where each value represents the sequencing count from NGS data.
222
+ - `adata.obs` – a pandas dataframe of samples metadata including "condition" and "replicate" columns.
223
+ - "condition": the condition for each sample in the experiment.
224
+ - "replicate": the replicate number for each sample in the experiment.
225
+ - `adata.var` – a pandas dataframe of targets in sgRNA library including "target" and "targetType" columns.
226
+ - "target": the target for each entry in reference sgRNA library. For single sgRNA libraries, this column can be
227
+ used to store gene names. For dual or multiple targeting sgRNA libraries, this column can be used to store gene pairs
228
+ or any other relevant information about the target.
229
+ - "targetType": the type of target for each entry in reference sgRNA library. Note that this column is used to
230
+ distinguish between different types of sgRNAs in the library and negative control sgRNAs can be defined as `"targetType" == "negative_control"`.
231
+ This is important for the phenotype calculation step.
232
+
233
+
234
+ ScreenPro2 has a built-in class for different types of CRISPR screen assays. Currently, there is a class called `PooledScreens`
235
+ that can be used to process data from pooled CRISPR screens. To create a `PooledScreens` object from an `AnnData` object,
236
+ you can use the following example code:
237
+
238
+ ```python
239
+ import pandas as pd
240
+ import anndata as ad
241
+ from screenpro.assays import PooledScreens
242
+
243
+ adata = ad.AnnData(
244
+ X = counts_df, # pandas dataframe of counts (samples x targets)
245
+ obs = meta_df, # pandas dataframe of samples metadata including "condition" and "replicate" columns
246
+ var = target_df # pandas dataframe of targets metadata including "target" and "targetType" columns
247
+ )
248
+
249
+ screen = PooledScreens(adata)
250
+ ```
251
+
252
+ <img width="600" alt="image" src="https://github.com/ArcInstitute/ScreenPro2/assets/53412130/bb38d119-8f24-44fa-98ab-7ef4457ef8d2">
253
+
254
+ ___
255
+
256
+ </details>
257
+
258
+ <details>
259
+ <summary>Run workflows</summary>
260
+ <br>
261
+
262
+ Once the screen object is created, you can use several available workflows to calculate the phenotype scores and statisitics by comparing each entry in reference sgRNA library between screen arms. Then, these scores and statistics are used to nominate hits.
263
+
264
+ ##### Drug Screen Workflow: calculate `gamma`, `rho`, and `tau` scores
265
+ `.calculateDrugScreen` method can be used to calculate the enrichment of each gene between screen arms for a drug
266
+ screen experiment. This method calculates `gamma`, `rho`, and `tau` scores for each gene and adds them to the
267
+ `.phenotypes` attribute of the `PooledScreens` object.
268
+
269
+ Here is an example for running the workflow on a [CRISPRi-dual-sgRNA-screens](#dcas9-crisprai-dual-sgrna-screens) dataset:
270
+
271
+ ```python
272
+ # Run the ScreenPro2 workflow for CRISPRi-dual-sgRNA-screens
273
+ screen.calculateDrugScreen(
274
+ t0='T0',
275
+ untreated='DMSO', # replace with the label for untreated condition
276
+ treated='Drug', # replace with the label for treated condition
277
+ score_level='compare_reps'
278
+ )
279
+ ```
280
+ ___
281
+ For example, in a Decitabine CRISPRi drug screen (see Figure 1B-C in [this bioRxiv paper](https://www.biorxiv.org/content/10.1101/2022.12.14.518457v2.full)), each phenotype score represents a comparison between different arms of the screen and `rho` scores shows the main drug phenotype as illustrated here:
282
+ <img width="800" alt="image" src="https://github.com/abearab/ScreenPro2/assets/53412130/b84b3e1f-e049-4da6-b63d-d4c72bc97cda">
283
+
284
+ ##### Flow cytometry based screen workflow: calculate phenotype score to compare high and low bins
285
+ `.calculateFlowBasedScreen` method can be used to calculate the enrichment of each target between high bin vs. low bin
286
+ of a flow cytometry-based screen experiment. This method calculates `PhenoScore` for each target and adds them to the
287
+ `.phenotypes` attribute of the `PooledScreens` object.
288
+
289
+ ```python
290
+ # Run the ScreenPro2 workflow for CRISPRi-dual-sgRNA-screens
291
+ screen.calculateFlowBasedScreen(
292
+ low_bin='low_bin', high_bin='high_bin',
293
+ score_level='compare_reps'
294
+ )
295
+ ```
296
+ ___
297
+
298
+ </details>
299
+
300
+ <details>
301
+ <summary>Benchmarking ScreenPro2 vs other CRISPR screen processing tools</summary>
302
+ <br>
303
+
304
+ Coming soon...
305
+
306
+ </details>
307
+
308
+ <!-- Benchmarking ScreenPro2 with other CRISPR screen analysis tools
309
+
310
+ ### More thoughtful NGS read trimming recovers more sgRNA counts
311
+
312
+ ### ScreenPro2 statistical analysis is more accurate than ScreenProcessing
313
+
314
+ ### ScreenPro2 is more flexible than ScreenProcessing
315
+
316
+ Not only does ScreenPro2 have more features than ScreenProcessing, but it is also more flexible. ScreenPro2 can process data from diverse CRISPR screen platforms and is designed to be modular to enable easy extension to custom CRISPR screen platforms or other commonly used platforms in addition to the ones currently implemented.
317
+
318
+ ### ScreenPro2 is faster than ScreenProcessing
319
+
320
+ Last but not least, ScreenPro2 runs faster than ScreenProcessing (thanks to [biobear](https://github.com/wheretrue/biobear)) for processing FASTQ files. -->
321
+
322
+
323
+ <br>
324
+
325
+ ### Step 3: Data visualization
326
+
327
+ Once the phenotypes are calculated, you can extract and explore the results using the `.phenotypes` attribute of the `PooledScreens` object. Currently, there are very limited functionalities built-in to visualize the results, but we are working on adding more features to make it easier for users. However, you can easily extract the results and use other libraries like `seaborn` and `matplotlib` in Python or `ggplot2` in R to visualize the results.
328
+
329
+ ___
330
+
331
+ ## Supported CRISPR Screen Platforms
332
+ One of the main goals of ScreenPro2 is to make it easy to process data from commonly used CRISPR screen platforms.
333
+ Also, it is designed to be modular to enable easy extension to custom CRISPR screen platforms or other commonly used
334
+ platforms in addition to the ones currently implemented.
335
+
336
+ ___
337
+ Currently, ScreenPro2 has easy-to-use workflows for the following CRISPR screen platforms:
338
+ ### dCas9 CRISPRa/i single-sgRNA screens
339
+ [Horlbeck et al., _eLife_ (2016)](http://dx.doi.org/10.7554/eLife.19760)
340
+
341
+ Horlbeck et al. developed a CRISPR interference (CRISPRi) and CRISPR activation (CRISPRa) screening platform that uses a single sgRNA within a single plasmid and then there are up to 10 sgRNAs per gene. The multiple sgRNAs per gene can be used to perfrom statistical comparisons in guide-level or gene-level between screen arms. [ScreenProcessing](https://github.com/mhorlbeck/ScreenProcessing) has been developed to process data from this type of screen. We reimplemented the same workflow in ScreenPro2 and it has all the necessary tools to process data from this type of screen.
342
+
343
+ <!-- TODO: Add link to example / tutorial -->
344
+
345
+ ### dCas9 CRISPRa/i dual-sgRNA screens
346
+ [Replogle et al., _eLife_ (2022)](https://elifesciences.org/articles/81856)
347
+
348
+ Replogle et al. developed a CRISPR interference (CRISPRi) and CRISPR activation (CRISPRa) screening platform that uses two sgRNAs per gene within a single plasmid, and it has been used to perform genome-scale CRISPRi screens. ScreenPro2 has all the necessary tools to process data from this type of screen.
349
+
350
+ <!-- TODO: Add link to example / tutorial -->
351
+
352
+ <!-- ### multiCas12a CRISPRi screens -->
353
+
354
+ ## License
355
+ ScreenPro2 is licensed under the terms of the MIT license (see [LICENSE](LICENSE) for more information) and developed
356
+ by Abolfazl (Abe) Arab ([@abearab](https://github.com/abearab)) as a Research Associate in the Gilbert lab at UCSF and Arc Institute.
357
+
358
+ ## Citation
359
+ If you use ScreenPro2 in your research, please cite the following paper.
360
+
361
+ Coming soon...
362
+
363
+ ## Development
364
+ ### Testing
365
+ Tests can be easily run using the `pytest` framework.
366
+