dtm2451 / dittoSeq

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

Adding 'padding' to DotPlot rows to highlight differences across celltypes? #116

Closed RobertWhitener closed 7 months ago

RobertWhitener commented 2 years ago

Hi, Thank you for this package! Im currently using it to generate DotPlots from our Seurat object because it is giving us much greater flexibility for the dotplots.

I've successfully generated a DotPlot which is grouped by celltype (columns), and then split each group by condition.

I'm wondering, is there a way to 'split' my featurelist (rows in my case) so that I can add some padding between each set of n numbers of features?

That would greatly help with the visualization of the data.

Thanks again!

DotPlot_Ditto <- dittoDotPlot(SUERAT, 
                              vars = rev(Genes_of_interest), 
                              group.by = 'CONDITION', 
                              split.by = 'CELLTYPE', 
                              split.nrow = 1, 
                              adjustment = 'relative.to.max' ,
                              scale = T, 
                              min.color = 'grey',
                              max.color = 'red',
                              y.labels = c('P','N','J')
                              ) + 
    coord_flip() +
    theme_minimal() +
    theme_replace(panel.background = element_blank(), strip.background = element_blank())

DotPlot_Ditto

Genes_of_interest is a vector of 48 features which is sorted by relative enrichment in each CELLTYPE, so adding a little padding between the rows that correspond to different CELLTYPEs would be amazing!

Robert

dtm2451 commented 2 years ago

:smile: Thanks, glad you're enjoying the package!

Hmmmm faceting in the genes/vars direction is not a feature of dittoDotPlot currently, but it's certainly something you could do outside of R with a tool like Illustrator. I'll have to think about if there's a good way to implement the user-input of how to 'split' genes into categories... I've also had the desire.

Some scoping of the potential feature add:

What I'm thinking is either a list structure like split.vars = list(celltype1 = c("gene1", "gene2"), celltype2 = c("gene3", "gene4")) or just a string vector (that's the same length as vars) like split.vars = c("celltype1", "celltype1", "celltype2", "celltype2"). Just something that I can have the function 1) interpret, and 2) add to the data.frame that's given to ggplot + facet_wrap() / facet_grid().

(With an SCE, because there's a 'rowData' = Seurat@meta.data equivalent for genes, there could be a simpler way where you could label your genes by celltype within the 'rowData'. Then I'd be able to let you just name that 'rowData' column... But that doesn't help you =p, just me scoping out this add further!)

j-andrews7 commented 8 months ago

FYI, this was also requested on Biostars earlier today.

dtm2451 commented 8 months ago

Good poke. Lot's on the ditto-docket rn, but this could be a quicker one. Multiple asks for this feature now & I know that I'd use this feature myself too, so this can at least jump to the top of the not-yet-started list!

dtm2451 commented 8 months ago

Implementation has begun in #142

Ultimately implemented around use of the normal vars input, where you give it a list to provide groupings. For example:

example("importDittoBulk", echo = FALSE)
logcounts(myRNA)[1:4,1:40] <- 0 # to add dropout to this mock bulk data
dittoDotPlot(
    myRNA,
    vars = list(
        'T cell'=c("gene1", "gene2"),
        'B cell'=c("gene3", "gene4")),
    group.by = "clustering")

image

Install via remotes::install_github("dtm2451/dittoSeq@dotplot-categories") to test and make use of this functionality for now. I still need to finalize with unit testing, updated documentation, and potentially some automated theme() updates to make the facet labels less intrusive, before deploying into the package.

dtm2451 commented 7 months ago

Got a chance to add to this implementation! Almost ready to merge now =).

image Made from code:

library(dittoSeq)
example(importDittoBulk, echo = FALSE)
logcounts(myRNA)[1:4,1:40] <- 0
dittoDotPlot(
    myRNA, group.by = "clustering",
    vars = list(
        Naive = paste0("gene", 1:5),
        Stimulated = paste0("gene", 6:8),
        Other = paste0("gene", 9:10)),
    vars.dir = "y"
)
dtm2451 commented 7 months ago

Merged in! This will make it into bioc-devel in the coming days!