Giter VIP home page Giter VIP logo

Comments (5)

falexwolf avatar falexwolf commented on July 18, 2024 1

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.

JPV95 avatar JPV95 commented on July 18, 2024

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.

falexwolf avatar falexwolf commented on July 18, 2024

No, sorry, there is no way to delete a row as storage is in contiguous arrays.

from anndata.

falexwolf avatar falexwolf commented on July 18, 2024

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.

wubaosheng avatar wubaosheng commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.