_Assay#

class missionbio.mosaic.assay._Assay(*args, **kwargs)#

Abstract class for all assays

Each of missionbio.mosaic.dna.Dna, missionbio.mosaic.cnv.Cnv, and missionbio.mosaic.protein.Protein are inherited from this base class, hence all of them have the following functionality:

_Assay objects can be filtered using Python’s slice notation. It requires two keys (barcodes, ids). Both could be a list of positions, a Boolean list, or a list of the respective values.

Load the sample.

>>> import missionbio.mosaic.io as mio
>>> sample = mio.load('/path/to/h5')

Select the first 250 cells (these aren’t necessarily the cells with the highest reads, they’re arbitrary cells) and the dna variants obtained from filtering.

>>> select_bars = sample.dna.barcodes()[: 250]
>>> select_vars = sample.dna.filter_variants()

Slice the dna assay for the selected cells and variants.

>>> filtered_dna = sample.dna[select_bars, select_vars]

Note: This example is for DNA, but the same can be done for any _Assay object.

Modifying data

add_layer(name, array)

Add layer to the assay

add_row_attr(name, value)

Add row attribute to the assay

add_col_attr(name, value)

Add column attribute to the assay

add_metadata(name, value)

Add metadata to the assay

del_layer(key)

Delete a layer from the assay layers.

del_row_attr(key)

Delete an attribute from the row_attrs.

del_col_attr(key)

Delete an attribute from the col_attrs.

del_metadata(key)

Delete an attribute from the metadata.

Selecting data

barcodes([label])

Get the list of barcodes.

clustered_barcodes([orderby, splitby, override])

Hierarchical clustering of barcodes.

ids()

Get the list of ids.

clustered_ids(orderby[, features, override])

Hierarchical clustering of ids.

set_ids_from_cols(col_names)

Rename the ids based on columns

reset_ids()

Resets ids if they were modified using _Assay.set_ids_from_cols()

drop(values[, value_type])

Drops the given values from the assay.

get_palette()

Get the label color palette.

set_palette([palette])

Set the label color palette.

get_labels([barcodes])

Get the labels corresponding to the barcodes.

set_labels(clusters[, default_label])

Set the labels for the barcodes.

set_selected_labels()

Custom clustering from scatter plots.

rename_labels(label_map)

Change the name of the labels.

get_attribute(attribute[, constraint, features])

Retrieve any attribute in the assay

Tertiary analysis methods

scale_data(layer[, output_label])

Z-score normalization

run_pca(attribute, components[, ...])

Principal component analysis

run_umap(attribute[, output_label])

Perform UMAP on the given data.

run_lda(layer, attribute, output_label[, cycles])

Perform LDA on a row attribute using a layer to type clusters.

cluster(attribute[, method])

Identify clusters of cells.

group_clusters(attribute)

Relabel clusters based on expression.

Visualizations

scatterplot(attribute[, colorby, features, ...])

Scatter plot for all barcodes.

heatmap(attribute[, splitby, features, ...])

Heatmap of all barcodes and ids.

signaturemap(attribute[, kind, nan_value, ...])

Flattened heatmap

violinplot(attribute[, splitby, features, title])

Violin plot for all barcodes.

ridgeplot(attribute[, splitby, features, title])

Ridge plot for all barcodes.

stripplot(attribute[, colorby, features, title])

Strip plot for all barcodes.

read_distribution([title])

Rank-ordered barcodes vs total reads.

feature_scatter(layer, ids, **kwargs)

Plot for given data across 2 ids.

Statistics

signature(attribute[, kind, nan_value])

The chosen signature for each cluster and feature.

test_signature(attribute[, kind])

Run a statistical test on the clusters