Coder Social home page Coder Social logo

Comments (1)

enblacar avatar enblacar commented on September 27, 2024 1

Hi @jaakoobb,

Thank you for using my package! There is no straight away parameter that handles this, as I do not generally expect NA in the metadata variables to plot, as they are also handled by na.value parameter in SCpubr::do_DimPlot().

However, I found a workaround for this. In short:

  • You turn your metadata variable from a factor to a character (if it is a factor).
  • Select all the NA values and turn them into a character value - i.e: "Remove".
  • Set the metadata variable as the Idents of the Seurat object via the Seurat::Idents() function.
  • Plot the DimPlot using the idents.keep parameter and providing all the values but the one you wish to bring to the back.

And that should do it. Here is a code example of it:

sample$seurat_clusters <- as.character(sample$seurat_clusters)
sample$seurat_clusters[is.na(sample$seurat_clusters)] <- "Remove"
sample$seurat_clusters <- as.factor(sample$seurat_clusters)
Seurat::Idents(sample)  <- sample$seurat_clusters

# Plot.
p <- SCpubr::do_DimPlot(sample, 
                        idents.keep = levels(sample)[levels(sample) != "Remove"])
p

This is how it looks with this hotfix:
do_DimPlot_NA_Hotfix

I will consider coding a workaround for this behaviour for the next update. Hope this helps in the meantime!

Enrique

from scpubr.

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.