Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Anti-correlated genes as a method of feature selection
python3 -m pip install anticor_features
You can also install using the setup.py script in the distribution like so:
python3 setup.py install
This should take less than one minute or even seconds if dependecies were already installed.
from anticor_features.anticor_features import get_anti_cor_genes
## Then feed in the expression matrix, with cells in columns, genes in rows
## and the feature names (all_features)
## and the species code (in gProfiler format, linked below)
anti_cor_table = get_anti_cor_genes(in_mat,
all_features,
species="hsapiens")
A list of the gProfiler accepted species codes is listed here: https://biit.cs.ut.ee/gprofiler/page/organism-list
The above call yields a pandas data frame that will give you the collected summary statistics, and let you filter based on the features annotated as "selected" in that column
>>> print(anti_cor_table.head())
gene pre_remove_feature pre_remove_pathway ... FDR num_sig_pos_cor selected
0 Xkr4 False False ... NaN NaN NaN
1 Rp1 False False ... NaN NaN NaN
2 Sox17 False False ... 0.001883 3406.0 True
3 Mrpl15 False True ... NaN NaN NaN
4 Lypla1 False True ... NaN NaN NaN
The NaNs are produced where the gene was not assayed for anti-correlations either from pre-filtering (the default is to remove genes in pathways related to mitochondria, ribosomes, and hemoglobin).
If you want to customize which GO terms are removed, or specify specific genes to exclude, you can do that with the pre_remove_features and pre_remove_pathways arguments
anti_cor_table = get_anti_cor_genes(in_mat,
all_features,
species="hsapiens",
pre_remove_features = ["ACTB","MT-COX1"])
If you follow along Scanpy's tutorial, then the only thing different would be swapping out:
[16]: sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)
[17]: sc.pl.highly_variable_genes(adata)
[18]: adata.raw = adata
[19]: adata = adata[:, adata.var.highly_variable]
for
from anticor_features.anticor_features import get_anti_cor_genes
anti_cor_table = get_anti_cor_genes(adata.X.T,
adata.var.index.tolist(),
species="hsapiens")
selected_table = anti_cor_table[anti_cor_table["selected"]==True]
print(selected_table)
## And you can save the anti-correlation dataframe into the adata object as well:
import pandas as pd
adata.var = pd.concat([adata.var,anti_cor_table], axis=1)
## And then we subset the data to only include the selected features!
adata.raw = adata
adata = adata[:, selected_table.index]
## Note that the downstream clusters and marker genes will be slightly different!
It should take ~ 1-2 minute(s) for the feature selection depending on your internet connection, the speed of the gprofiler server (if looking up pathways like ribosomes, mitochondria, etc to remove), but will also scale a bit with the complexity of the dataset. For example, the tabula muris dataset used in the manuscript took ~ 60 minutes, in part because nearly every gene was expressed at appreciable values in a subset of the cells.
scratch_dir=</local/path/to/dataset/directory>
. This ensures that each dataset will be analyzed properly and there won't be conflicts in terms of where files get written.You can also use this tool at the command line, if you have either a .tsv or an hdf5 file, with the matrix under the key "infile"
python3 -m anticor_features.anticor_features -i exprs.tsv -species mmusculus
or something similar. This outputs the pandas table to a tsv in the same folder as the input file
See the help section for more detailed usage of the command line interface:
python3 -m anticor_features.anticor_features -h
This package is available via the AGPLv3 license.
FAQs
Anti-correlation based feature selection for single cell datasets
We found that anticor-features demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.