_Assay

Contents

_Assay#

missionbio.mosaic.assay._Assay

class _Assay(*args, **kwargs)#

Abstract class for all assays

Each of Dna, Cnv, and 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.

Variables#

_Assay.selected_ids

The ids selected on the heatmap

_Assay.selected_bars

The barcodes selected on the scatterplot

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.

rename_sample(old_name, new_name)

Rename sample to a new_name

Selecting data#

barcodes([label])

Get the list of barcodes.

clustered_barcodes([orderby, splitby, ...])

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 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, ...])

Retrieve any attribute in the assay

hierarchical_cluster(dat[, index])

Get the hierarchical clustering order of the index of the dataframe.

Transforming data#

convolve(data, labels, convolve)

Convolve the data in-place based on the given labels.

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 showing the signature profile for each unique label

crosstabmap(columns[, index, normalize, ...])

Crosstab heatmap for all barcodes.

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

Violin plot for all barcodes.

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

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, splitby, ...])

The chosen signature for each cluster and feature.

test_signature(attribute[, kind])

Run a statistical test on the clusters

crosstab(columns[, index, normalize])

Compute a simple cross-tabulation of two attributes.

Parameters:
argslist

To be passed to missionbio.h5.data.Assay class.

kwargsdict

To be passed to missionbio.h5.data.Assay class.