Mosaic

A basic tutorial on how to use Mosaic to analyse DNA + Protein data can be found here.

Loading a sample

Any .h5 file can be loaded as a Sample object using:

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

Once the analysis is complete, it can be saved using:

>>> mio.save(sample, '/path/to/save/h5')

Data structure

              missionbio.h5.assay.Assay
                (h5 reader and writer)
                         |
                         |
           missionbio.mosaic.assay._Assay
          (basic interactivity and plotting)
                         |
                         |
             ---------------------------
             |           |             |
             |           |             |
             |           |             |
            Dna         Cnv         Protein

(Sample-specific functionality, such as normalization)

missionbio.h5.assay.Assay is a module for reading and writing .h5 files. It stores the information of the assay using:

  1. metadata (add_metadata / del_metadata):

    Dictionary containing the metrics of the assay.

  2. row_attrs (add_row_attr / del_row_attr):

    Dictionary containing ‘barcode’ as one of the keys. All the values must be of the same length, i.e., match the number of barcodes. This is the attribute where ‘label’, ‘pca’, and ‘umap’ values are added.

  3. col_attrs (add_col_attr / del_col_attr)):

    Dictionary containing ‘ids’ as one of the keys. All the values must be of the same length, i.e., match the number of ids. ‘ids’ contains variants for DNA assays and antibodies for Protein assays.

  4. layers (add_layer / del_layer):

    Dictionary containing ‘read_counts’ as one of the metrics. All the values have the shape (num barcodes) x (num ids). This is the attribute where ‘normalized_counts’ will be added.

_Assay builds on top of the h5 assay to incorporate functionality specific to tertiary analysis. It also provides generic functions for visualizing the data.

Dna, Cnv, and Protein are subclasses of the above class. Therefore, they inherit all the plotting and interactive functionality from the _Assay class. Each one includes methods specific to the assay, such as normalization and cell type identification.

Sample
  |
  |-- dna
  |-- cnv
  |-- protein
  |-- cnv_raw
  |-- protein_raw

Sample object contains all three of the above assays along with the raw counts for the same. The raw counts are also stored as the respective assay objects.

Interface

Modules

io

Module to read and write h5 files

utils

Utility functions

constants

Colors and keys for layers and attributes

Classes

_Assay

Abstract class for all assays

Dna

Container for DNA data.

Cnv

Container for CNV data.

Protein

Container for Protein data

Sample

Container for multiple assays.