dtm2451 / dittoSeq

Color blindness friendly visualization of single-cell and bulk RNA-sequencing data
MIT License
188 stars 18 forks source link

working with dataframe #119

Closed cstrlln closed 1 year ago

cstrlln commented 1 year ago

I noticed in the dittodimplot information that the object can be a dataframe. Could you give an example on how to do this? Love using dittoSeq for transcriptomic data but I'm working with other multiomics data where I created a dataframe containing the umap coordinates and a few columns with values, including for example a column with cell cluster identity. How do you suggest using this?

If dbh is the dataframe

As I was not sure how to proceed I created another dataframe containing the coordinates (which I took from the reducedDims of my SCE object):

umap <- data.frame(umap1=dbh$umap1, umap2=dbh$umap2)

And tried something like this:

dittoSeq::dittoDimPlot(dbh, var = dbh$cell_clusters, reduction.use = umap, dim.1 = umap1, dim.2 = umap2,
                       do.label = TRUE,
                       labels.size = 6,
                       legend.size = 1,
                       legend.show = FALSE)

When doing that I get this error:

Error in .subset(x, j) : only 0's may be mixed with negative subscripts

dtm2451 commented 1 year ago

Hey! Sorry for the long delay.

There's some confusion here.

First, to answer your question of how to construct the plot you want, since you have everything needed in a data.frame already, you can use dittoViz -- a data.frame-focused version of dittoSeq that I've been working on. It's not fully documented, and what documentation does exist isn't fully converted over from dittoSeq counterparts, but feel free to create another issue over there if you can't figure it out! https://github.com/dtm2451/dittoViz. You can install with remotes::install_github("dtm2451/dittoViz"). (Compared to dittoSeq, dittoViz is still in earlier stages of development, but I do intend to submit it to CRAN or Bioconductor (probably Bioconductor) as soon as I have time to fill in documentation, unit tests, and vignettes!)

dittoViz::scatterPlot(
    data_frame = dbh,
    x.by = "umap1",
    y.by = "umap2",
    color.by = "cell_clusters",
    do.label = TRUE,
    labels.size = 6,
    legend.show = FALSE)

Now for dittoSeq::dittoDimPlot's data.frame functionality: The purpose of this functionality is creation of PCA plots for bulk RNAseq data. The path still requires that you give a 'SummarizedExperiment' (SE) object to the object input. It sounds like you wouldn't have that, so I don't think this path works for your target data. SE objects don't have a slot to hold dimensionality reductions, unlike 'SingleCellExperiment' and 'Seurat' objects, so there needed to be a way to provide that separately to the function. That's the entirety of why reduction.use can take in an embeddings matrix (or data.frame). But it's just for that specific use case. The function still assumes your object is "A Seurat, SingleCellExperiment, or SummarizedExperiment object", and is likely erroring because it is not.

cstrlln commented 1 year ago

Thank you!