Package: cpa-tools
CPA - Compositional Perturbation AutoencoderWhat is CPA?CPAis a framework to learn the effects of perturbations at the single-cell level. CPA encodes and learns phenotypic drug responses across different cell types, doses, and combinations. CPA allows:Out-of-distribution predictions of unseen drug and gene combinations at various doses and among different cell types.Learn interpretable drug and cell-type latent spaces.Estimate the dose-response curve for each perturbation and their combinations.Transfer pertubration effects from on cell-type to an unseen cell-type.Enable batch effect removal on a latent space and also gene expression space.InstallationInstalling CPAYou can install CPA using pip and also directly from the github to access latest development version.
See detailed instructionshere.How to use CPASeveral tutorials are availablehereto get you started with CPA.
The following table contains the list of tutorials:DescriptionLinkPredicting combinatorial drug perturbations-Predicting unseen perturbations uisng external embeddings enabling the model to predict unseen reponses to unseen drugs-Predicting combinatorial CRISPR perturbations-Context transfer (i.e. predict the effect of a perturbation (e.g. disease) on unseen cell types or transfer perturbation effects from one context to another) demo on IFN-β scRNA perturbation dataset-Batch effect removal in gene expression and latent space-How to optmize CPA hyperparamters for your dataWe provide atutorialon how to optimize CPA hyperparameters for your data.Datasets and Pre-trained modelsDatasets and pre-trained models are availablehere.Recepie for Pre-processing a custom scRNAseq perturbation datasetIf you have access to you raw data, you can do the following steps to pre-process your dataset. A raw dataset should be ascanpyobject containing raw counts and available required metadata (i.e. perturbation, dosage, etc.).Pre-processing stepsCheck for required information in cell metadata:
a) Perturbation information should be inadata.obs.
b) Dosage information should be inadata.obs. In cases like CRISPR gene knockouts, disease states, time perturbations, etc, you can create & add a dummy dosage in youradata.obs. For example:adata.obs['dosage']=adata.obs['perturbation'].astype(str).apply(lambdax:'+'.join(['1.0'for_inx.split('+')])).valuesc) [If available] Cell type information should be inadata.obs.
d) [Multi-batchintegration] Batch information should be inadata.obs.Filter out cells with low number of counts (sc.pp.filter_cells). For example:sc.pp.filter_cells(adata,min_counts=100)[optional]sc.pp.filter_genes(adata,min_counts=5)Save the raw counts inadata.layers['counts'].adata.layers['counts']=adata.X.copy()Normalize the counts (sc.pp.normalize_total).sc.pp.normalize_total(adata,target_sum=1e4,exclude_highly_expressed=True)Log transform the normalized counts (sc.pp.log1p).sc.pp.log1p(adata)Highly variable genes selection:
There are two options:
1. Use thesc.pp.highly_variable_genesfunction to select highly variable genes.python sc.pp.highly_variable_genes(adata, n_top_genes=5000, subset=True)2. (Highly Recommendedspecially forMulti-batchintegration scenarios) Use scIB'shighly variable genes selectionfunction to select highly variable genes. This function is more robust to batch effects and can be used to select highly variable genes across multiple datasets.python import scIB adata_hvg = scIB.pp.hvg_batch(adata, batch_key='batch', n_top_genes=5000, copy=True)Congrats! Now you're dataset is ready to be used with CPA. Don't forget to save your pre-processed dataset usingadata.write_h5adfunction.Support and contributeIf you have a question or new architecture or a model that could be integrated into our pipeline, you can
post anissueReferenceIf CPA is helpful in your research, please consider citing theLotfollahi et al. 2023@article{lotfollahi2023predicting,
    title={Predicting cellular responses to complex perturbations in high-throughput screens},
    author={Lotfollahi, Mohammad and Klimovskaia Susmelj, Anna and De Donno, Carlo and Hetzel, Leon and Ji, Yuge and Ibarra, Ignacio L and Srivatsan, Sanjay R and Naghipourfar, Mohsen and Daza, Riza M and 
    Martin, Beth and others},
    journal={Molecular Systems Biology},
    pages={e11517},
    year={2023}
}