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) from adata.raw matrix.

Parameters
  • adata – Annotated data matrix.

  • groupbyadata.obs field used for marker calculation

  • keyadata.uns key that has computed markers

  • p_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")