lazyslide.tl.RNALinker#

class RNALinker(agg_features, others, gene_name=None)#

Bases: object

Link the aggregated WSI features with other omics data.

Parameters:
agg_featuresAnnData

The aggregated WSI features.

othersAnnData

Other omics data, like RNA-seq, must have the same number of observations as agg_features.

gene_namestr, default: None

The key to use for the name of the omics data.

associate(method='linear_reg', score_key=None, key_added='association_score')#

Associate scores with other omics.

Parameters:
method{“pearson”, “spearman”, “kendall”, “linear_reg”, “lasso”}, default: “linear_reg”

The method to use for association analysis.

score_keystr, default: None

The key in agg_features.obs containing the scores to associate. If None, uses the last score key set by score().

key_addedstr, default: “association_score”

The key to store the association scores in omics_matrix.var.

associated_genes(n_genes=5, gene_name=None)#

Get the top and bottom associated genes.

Parameters:
n_genesint, default: 5

The number of top and bottom genes to return.

gene_namestr, default: None

The column name in omics_matrix.var to use as gene names. If None, uses the index of omics_matrix.var.

Returns:
dict

A dictionary with keys ‘top’ and ‘bottom’, each containing a DataFrame of the most and least associated genes.

plot_rank(n_genes=5, gene_name=None)#

Plot the rank of the association score.

Parameters:
n_genesint, default: 5

The number of top and bottom genes to annotate on the plot.

gene_namestr, default: None

The column name in omics_matrix.var to use as gene names.

plot_score(ax=None)#

Plot the score distribution for the score group and others.

Parameters:
axmatplotlib.axes.Axes, default: None

The axes to plot on. If None, a new figure is created.

score(groupby, score_group, scale=True, test_method='t-test', n_features=100, key_added=None)#

Score a group of samples based on the aggregated features.

The score will be higher for the score group and lower for the rest.

Parameters:
groupbystr

The key in the obs of agg_features.

score_groupstr

The specific group in the column of groupby to score.

scalebool, default: True

Scale the features between -1 and 1.

test_methodstr, default: “t-test”

The method to use for ranking omics features like genes.

n_featuresint or str, default: 100

The number of features to use for scoring. If “all”, use all features.

key_addedstr or None, default: None

The key to store the scores in the obs of agg_features. If not specify, f”{score_group}_score” will be added to the obs of agg_features.