Comments (5)
Checkout the basic tutorial.
What you want specifically is
non_mito_genes_list = [name for name in adata.var_names if not name.startswith('MT-')]
adata_no_mito_genes = adata[:, non_mito_genes_list]
Or you can also do
mito_gene_list = sc.queries.mitochondrial_genes()
mito_gene_indicator = np.in1d(adata.var_names, mito_gene_list)
adata_no_mito_genes = adata[:, ~mito_gene_indicator]
where ~
inverts the boolean indicator array, making it a mask.
Depending on the scenario, one or the other will be more convenient.
PS: AnnData stores observations as rows and variables as columns as common in machine learning, statistics and Python, but opposite to the genomics convention.
from anndata.
I ran the above solution, only to get memory error, I am running 64 bit python, is there a way to delete a row based on observation value?
essentially
if anndata['value'] == "threshold"
delete()
from anndata.
No, sorry, there is no way to delete a row as storage is in contiguous arrays.
from anndata.
How come you are getting a memory error from the above? Are you dealing with a huge matrix on a machine with very little memory?
from anndata.
No, sorry, there is no way to delete a row as storage is in contiguous arrays.
you can do like this:
t = adata.obs.drop(index=["C_DeepM_r_2_FRAS210239463_1r"])
adata= adata[adata.obs["sample_index"].isin(t["sample_index"].to_list())]
from anndata.
Related Issues (20)
- Invalid type of X ValueError lists unclear accepted type HOT 1
- Include metadata when converting to Pandas DataFrame HOT 4
- `to_df` docstrings
- dask.array.store but with anndata schema HOT 1
- Indexing With a Dask Array HOT 5
- adata.raw = adata HOT 1
- GPU CI tests failing HOT 2
- Add working `GroupStorageType` type annotation
- 0.10.6 - Cannot write files due to implicit conversion to str dtype. HOT 2
- Saving .h5ad with pd.Series in .uns results in IORegistryError HOT 3
- `read_elem_as_dask` HOT 8
- `FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config'` on CI HOT 2
- Upcoming Scipy 1.13 incompatible with file-backed sparse matrices
- CZI files' `var` count changd
- `/` in column names makes AnnData Zarr object unreadable on windows HOT 12
- String indexes in var lead to UserWarning HOT 1
- Move tests out of the package
- Refactor `BaseCompressedSparseDataset` and subclasses to remove `backed_{csr,csc}_matrix`
- concat_on_disk should use int64 indptrs by default so that it can concatenate large files HOT 4
- TypeError: Can't implicitly convert non-string objects to strings HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anndata.