More sparsity support, empty layers & experimental plotting features
Any layer can be created from sparse matrix
This now works:
G = 1000
C = 100
S = sparse.eye(G, C)
with loompy.connect("test.loom") as ds:
ds["layer"] = S
Fixes #66.
Create empty file
loompy.new()
creates an empty loom file, and returns it as a context manager. The file can then be populated with data. This is especially useful when you're building a dataset incrementally, e.g. by pooling subsets of other datasets:
with loompy.new("outfile.loom") as dsout:
for sample in samples:
with loompy.connect(sample) as dsin:
logging.info(f"Appending {sample}.")
dsout.add_columns(ds.layers, col_attrs=dsin.col_attrs, row_attrs=dsin.row_attrs)
As a consequence, create_append()
is now deprecated.
Fixes #42.
Experimental plotting features
ds.pandas()
to return a Pandas DataFrame for the whole matrix, or selected parts. The interface is intended to simplify plotting, since many plotting libraries take Pandas as input. The interface is experimental, and e.g. lacks support for layers.
ds.embedding()
and ds.embeddings()
to find attributes that are >1-dimensional. Again intended to support plotting, by making it easy to find the X/Y coordinates without knowing if they are stored as TSNE
, PCA
or something else. The interface is liable to change (in particular, I'd like to find a shorter name than "embedding").
Two useful colormaps: loompy.zviridis
is a zero-inflated version of viridis
, good for plotting zero-inflated data. loompy.cat_colors()
is a function that generates N distinct colors, in pleasing and distinguishable hues, for large N.
Contributes to #62.