-
Hello! I have seurat tSNE coordinates for my cells:
And I want them to be transfered into my loom files which I concatenated: How can I transfer my tsne coordinates onto the matching cell IDs in my concatenated loom file? I had a look at #37 but running the suggested code I got this really strange output... not entirely sure what This is the first time I have tried using python so please let me know I haven't missed out on something! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
@AAA-3, you should not use I'd do something along the lines of import pandas as pd
from anndata import read_loom
import scvelo as scv
WT3 = read_loom(...)
WT4 = read_loom(...)
# read rest of data, clean var names
sample_one = WT3.concatenate(...)
tsne_coords = pd.read_csv(...)
# Subset to observations present in both `sample_one` and `tsne_coords`
tsne_coords = tsne_coords.loc[tsne_coords.index.isin(sample_one.obs_names), :]
sample_one = sample_one[sample_one.obs_names.isin(tsne_coords.index), :]
# Make sure `sample_one` and `tsne_coords` are aligned
tsne_coords = tsne_coords.loc[sample_one.obs_names, :]
# Add tSNE coordinates to `sample_one`
sample_one.obsm['X_tsne'] = tsne_coords.values Some thoughts/remarks:
import pandas as pd
from anndata import read_loom
import scvelo as scv
tsne_coords = pd.read_csv(...)
WT3 = read_loom(...)
WT3.var_names_make_unique()
tsne_coords = tsne_coords.loc[tsne_coords.index.isin(WT3.obs_names), :]
WT3 = WT3[WT3.obs_names.isin(tsne_coords.index), :]
WT3.obsm['X_tsne'] = tsne_coords.values
tsne_coords = pd.read_csv(...)
WT4 = read_loom(...)
...
sample_one = WT3.concatenate(...) |
Beta Was this translation helpful? Give feedback.
-
Hello @WeilerP I was wondering if you could help me here since my issue is a continuation of the above. I managed to import my seurat clusters using the same methods as above. However, when I try to load my saved loom file, I get an error each time I set the
Without setting the Seeing as the information is available in the loom file, I assume that it is in an incorrect format...would it have something to do with it being an array? I notice that there is no |
Beta Was this translation helpful? Give feedback.
-
For anyone else who is having this issue: The problem was resolved when instead of saving it as a loom I saved it as a H5AD file :) Issue can be marked as solved |
Beta Was this translation helpful? Give feedback.
For anyone else who is having this issue: The problem was resolved when instead of saving it as a loom I saved it as a H5AD file :) Issue can be marked as solved