You can do this pretty simply with
dittoHeatmap(). It can grab the proper genes and samples subsets of your counts data and even automatically add annotation based on the type of samples. The inputs for such subsetting are
cells.use (dittoSeq is built to work for single-cell data as well.)
# Import your DESeqDataSet object into the (very similar) format that dittoSeq natively understands:
RNAdata <- importDittoBulk(your_dds)
# If your `sample types` data was likely in the dds as you would have used it for DE
# The import function will retain it then, but you can see the names of all kept metadata with
# Access of metadata can be achieved with:
# Make the heatmap
object = RNAdata,
genes = DE.genes,
# cells.use can be used in any of these three ways.
# Each are easiest for different situations.
# Use ONE.
cells.use = names_of_wanted_samples # example: colnames(RNAdata)[RNAdata$metadata_name %in% c("x","y")]
cells.use = indices_of_wanted_samples # example: 1:4
cells.use = logical_TRUE_for_wanted_samples # example: RNAdata$metadata_name %in% c("x","y")
Note on dittoSeq installation: If you are in R 4.0, you can install through Bioconductor with
BiocManager::install("dittoSeq"). If not, you can still install it via the github (I have tested myself for R≥3.6.2, but this method should let you install in any R version.)
Additional tweaks to the plot can be made by providing additional
?pheatmap inputs, but the above code should accomplish the goals that you mention here.
modified 3 days ago
3 days ago by
dtm2451 • 20