sc_utils.get_markers¶
- sc_utils.get_markers(adata, groupby, key='rank_genes_groups', p_val_cutoff=0.05, logfc_cutoff=0.5)[source]¶
Extract markers from adata into Seurat-like table
Extracts markers after they are computed by
scanpy
. Produces Seurat-like table with fields"p_val", "avg_logFC", "pct.1", "pct.2", "p_val_adj", "cluster", "gene"
Calculates the percentage of cells that express a given gene in the target cluster (
pct.1
field) and outside the cluster (pct.2
field) fromadata.raw
matrix.- Parameters
adata – Annotated data matrix.
groupby –
adata.obs
field used for marker calculationkey –
adata.uns
key that has computed markersp_val_cutoff – Drop all genes with adjusted p-value greater than or equal to this
logfc_cutoff – Drop all genes with average logFC less than or equal to this
- Returns
Returns a pandas dataframe with above listed columns, optionally
subsetted on the genes that pass the cutoffs.
p_val
field is a copy of adjusted p-value field.
Example
>>> sc.tl.rank_genes_groups(adata, "leiden", method="wilcoxon", n_genes=200) >>> markers = sc_utils.get_markers(adata, "leiden") >>> markers.to_csv("markers.csv")