velocyto-notebooks icon indicating copy to clipboard operation
velocyto-notebooks copied to clipboard

How can I achieve key such as 'TSNE1' or ''Clustername'' in the vlm.ca?

Open EularTang opened this issue 5 years ago • 7 comments

Thanks for you excellent script. But when I run own data ,which have generate '.loom' file, I always face the traceback following. I notice that the sample you used have those key in dict and can not face error? So ,how should I do to slove it to continue the program.

vlm.ca["TSNE1"] Traceback (most recent call last): File "", line 1, in KeyError: 'TSNE1'

vlm.ca["ClusterName"] Traceback (most recent call last): File "", line 1, in KeyError: 'ClusterName'

EularTang avatar Oct 14 '18 08:10 EularTang

It is simply because your loom file does not contain such information, it is not supposed to, the notebook was of a particular example where we had precomputed those.

In your case, just compute tsne and clusters and pass them to the right functions/assignments.

gioelelm avatar Oct 14 '18 08:10 gioelelm

It is simply because your loom file does not contain such information, it is not supposed to, the notebook was of a particular example where we had precomputed those. In your case, just compute tsne and clusters and pass them to the right functions/assignments.

Thank you for your attention ! I've done t-sne and cluster, so I should edit the object vlm.ca directly, right? or changing loom files? In fact,I tried many data using velocyto and velocyto run10X, but they all had very few keys in 'vl.ca'. I command line is: velocyto run10x - m ~ / rfdata / 10 x/mm10_rmsk GTF ~ / scRNA/sample / 10 x/neurons ~ / rfdata / 10 x/refdata - cellranger - mm10-1.2.0 / genes/genes. GTF

EularTang avatar Oct 14 '18 09:10 EularTang

Exactly you can either: Write on the loom file using loompy Modify the vlm.ca in memory as you are suggesting Or just pass the variable to the downstream functions (for example set_clusters)

Finally vlm.ca is almost empty because you did not pass a table of metadata (e.g. sample.tsv) to the command. This is definetelly not necessary, but just a nice facility, since you can anyways add column attributes later using loompy.

gioelelm avatar Oct 14 '18 09:10 gioelelm

Hello, Would it be possible to provide a notebook example of how to calculate the tSNE/clusters and write them into the loom file? Or how to merge Seurat analyzed tSNE/cluster info into the loom file? Many thanks!

IrinnaP avatar Feb 14 '19 16:02 IrinnaP

@IrinnaP Hi. I have the same question. Were you able to find out how you could add tSNE/clusters info to the loom file?

Sabermea avatar Mar 05 '19 21:03 Sabermea

To save tSNE and cluster name attributes into the loom file, do this;

import loompy
with loompy.connect("mydata.loom") as ds:
    ds.ca.TSNE1 = ... # a list or numpy array of floats giving the first tSNE coordinate of each cell
    ds.ca.TSNE2 = ... # a list or numpy array of floats giving the second tSNE coordinate of each cell
    ds.ca.ClusterName = ... # a list or numpy array of strings giving the cluster name for each cell

Replace the ellipses (...) in each case with a list or numpy array with length equal to the number of columns (cells) in the loom file.

You can add other attributes to the Loom file in the same way, both for cells (columns, using ds.ca.SomeAttributename) and genes (rows, using ds.ra.SomeAttributeName).

For more information about how to work with loompy, see http://loompy.org and click through to the documentation, which has tutorials and API reference.

slinnarsson avatar Mar 06 '19 09:03 slinnarsson

I understand how to add the name attributes to the loom file, however what did you use to calculate the TSNE coordinates, and how did you get the specific coordinates per cell back?

ArcusGears avatar Nov 25 '19 19:11 ArcusGears