Regressing out genes #492
Copy link
Copy link
Open
Labels
good first issueeasy first issue to get started in OSS community contribution!easy first issue to get started in OSS community contribution!
Description
Activity
Hi,
I'm not entirely sure how Seurat does it, but I assume you could take the mean expression level (or mean z-score) of a couple of genes, store that in a.varcolumn, and regress that out bysc.pp.regress_out(adata, var_col)?Something like this:
adata.var['genes_of_interest'] = adata.X[:,gene_list].mean(0) sc.pp.regress_out(adata, genes_of_interest)If you want to ensure an equal contribution of all the genes to the gene score without weighting by mean gene expression, you could first use
sc.pp.scale()on a copy of theadataobject like this:adata_tmp = adata.copy() sc.pp.scale(adata_tmp) adata.var['genes_of_interest'] = adata_tmp.X[:,gene_list].mean(0) sc.pp.regress_out(adata, genes_of_interest)Note that I have not tested this code... so no guarantees ;).
This would be very easy to implement with:
sc.get.obs_df(adata, keys).That would not solve the problem of (I believe) constant genes giving errors.
- addedgood first issueeasy first issue to get started in OSS community contribution!easy first issue to get started in OSS community contribution!
on Jan 24, 2021
Metadata
Metadata
Assignees
Labels
good first issueeasy first issue to get started in OSS community contribution!easy first issue to get started in OSS community contribution!
In Seurat, there is an option of selecting a list of genes in the pre-processing regressOut function. I was wondering if there was similar functionality in Scanpy. Doing something like below does not work for me as a lot of the cells have 0 expression, giving me a PerfectSeparationError.
adata.obs[gene] = adata[:, adata.var_names==gene].Xsc.pp.regress_out(adata,gene)Any help would be appreciated. Thank you!