snapatac2.tl.add_cor_scores#
- snapatac2.tl.add_cor_scores(network, *, gene_mat=None, peak_mat=None, select=None, overwrite=False)[source]#
Add Spearman correlation scores to network edges.
Use this function to score existing region-gene, gene-gene, or motif-region associations from matched cell-by-peak and cell-by-gene matrices.
Anti-Patterns#
Do NOT pass matrices with different cell order or different
obs_names.Do NOT expect missing edges to be created; only existing network edges are scored.
- param network:
Graph containing
NodeDatanodes andLinkDataedges.- type network:
PyDiGraph- param gene_mat:
Cell-by-gene matrix with gene names in
.var_names.- type gene_mat:
AnnData|AnnDataSet|None- param peak_mat:
Cell-by-region matrix with region names in
.var_names.- type peak_mat:
AnnData|AnnDataSet|None- param select:
Gene ids to score. If None, score all eligible target genes.
- type select:
- param overwrite:
If True, recompute existing
cor_scorevalues.- type overwrite:
- returns:
Updates edge
cor_scoreattributes innetworkin place.- rtype:
None
Examples
>>> import snapatac2 as snap >>> adata = snap.datasets.pbmc5k(type="annotated_h5ad") >>> gene_mat = snap.pp.make_gene_matrix(adata, snap.genome.hg38) >>> network = snap.tl.init_network_from_annotation(list(adata.var_names[:10]), snap.genome.hg38) >>> snap.tl.add_cor_scores(network, peak_mat=adata, gene_mat=gene_mat) >>> network.num_edges() >= 0 True