Modify AnnDataSets obs matrix #124
Unanswered
nvelthuijs
asked this question in
Q&A
Replies: 1 comment 2 replies
-
The code below is working for me:
which version are you using? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I've been trying to work with a 20-sample scATAC library, but keep having issues with accessing the .obs-matrix.
What is the intended way of adding columns to or manipulating values in the .obs?
For example, say I want to take the fragment counts from the original adata_objects
data.adatas.obs["n_fragment"]
and write their log10 todata.obs["n_fragment_log10"]
?I can get the values:
But how do you write that to data.obs?
data.obs["n_fragment_log10"] = np.log10(data.adatas.obs["n_fragment"])
AttributeError: 'DataFrame' object has no attribute 'with_column'
data.obs = data.obs[:].with_columns(np.log10(data.adatas.obs["n_fragment"].alias("n_fragment_log10")))
PanicException: called `Result::unwrap()` on an `Err` value: H5Ldelete(): no name
data.obs[:] = data.obs[:].with_columns(np.log10(data.adatas.obs["n_fragment"].alias("n_fragment_log10")))
ValueError: Cannot __setitem__ on DataFrame with key: 'slice(None, None, None)' of type: '<class 'slice'>' and value: 'shape: (62_223, 3)
Thanks in advance,
Niels
Beta Was this translation helpful? Give feedback.
All reactions