ChIPseeker icon indicating copy to clipboard operation
ChIPseeker copied to clipboard

change the method of plotting heatmap

Open MingLi-929 opened this issue 2 years ago • 0 comments

This pr change the way of plotting heatmap from base system to ggplot system. It adds the function of gradient color by giving palette parameter, which is the palette of gradient color.

There are two ways to plot the heatmap. The first is giving a created matrix to tagHeatmap() fucntion.

library(TxDb.Hsapiens.UCSC.hg19.knownGene)
files <- getSampleFiles()
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
mt <- getTagMatrix(peak = files[[5]],TxDb = txdb,
                   upstream = 1000,downstream = 1000,
                   type = "start_site",by = "gene",
                   weightCol = "V5")

tagHeatmap(mt)

t1 The second is to use peakHeatmap() to do all things in one steps.

peakHeatmap(files[[4]],TxDb = txdb)

t2

If users wanna to speed up the process, a binning method can be used by specifing the nbin.

peakHeatmap(files[[4]],TxDb = txdb, nbin = 800)

t3

Since this method use ggplot system, users can use ggplot method to change

peakHeatmap(files[[4]],TxDb = txdb, nbin = 800) +
	scale_fill_distiller(palette = "RdYlGn")

t4

a list of peaks can also be plotted.

peakHeatmap(files,TxDb = txdb)

t5

Update the function to plot the heatmap around the gene body regions

library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene

# plot body region
peakHeatmap(peak = files[[4]],
            TxDb = txdb,
            upstream = NULL,
            downstream = NULL,
            by = "gene",
            type = "body",
            nbin = 800)

t6

# extend body region with rel object
peakHeatmap(peak = files[[4]],
            TxDb = txdb,
            upstream = rel(0.2),
            downstream = rel(0.2),
            by = "gene",
            type = "body",
            nbin = 800)

t7

# extend body region with actual number
peakHeatmap(peak = files[[4]],
            TxDb = txdb,
            upstream = 1000,
            downstream = 1000,
            by = "gene",
            type = "body",
            nbin = 800)

t8

Can we plot heatmaps with different gene sets? like the plots with genesX and gene19 in deeptools).

txdb1 <- transcripts(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb2 <- unlist(fiveUTRsByTranscript(TxDb.Hsapiens.UCSC.hg19.knownGene))

txdb <- list(gene19 = txdb1, geneX = txdb2)
peakHeatmap_multiple_Sets(peak = files[[4]],
                          upstream = 1000,downstream = 1000,
                          by = c("gene19","geneX"),
                          type = "start_site",
                          TxDb = txdb,nbin = 800)

t9

sample <- list(files[[4]],files[[5]])
peakHeatmap_multiple_Sets(peak = files[4:5],
                          upstream = 1000,
                          downstream = 1000,
                          by = c("gene19","geneX"),type = "start_site",
                          TxDb = txdb,nbin = 800)

t10

the proportion of picture can be adjusted automactically

txdb1 <- transcripts(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb2 <- unlist(fiveUTRsByTranscript(TxDb.Hsapiens.UCSC.hg19.knownGene))[1:10000,]

txdb <- list(gene19 = txdb1, geneX = txdb2)
peakHeatmap_multiple_Sets(peak = files[[4]],
                          upstream = 1000,downstream = 1000,
                          by = c("gene19","geneX"),
                          type = "start_site",
                          TxDb = txdb,nbin = 800)

t11

Can we plot heatmaps with different gene sets? like the plots with genesX and gene19 in deeptools).

peak_Profile_Heatmap function is also created to meet the need of ploting profiling plot and heatmap together, just like deeptools output.

peak_Profile_Heatmap(peak = files[[4]],
                     upstream = 1000,
                     downstream = 1000,
                     by = "gene",
                     type = "start_site",
                     TxDb = txdb3,
                     nbin = 800)

t12

peak_Profile_Heatmap(peak = files[[4]],
                     upstream = 1000,
                     downstream = 1000,
                     by = c("gene19","geneX"),
                     type = "start_site",
                     TxDb = txdb,nbin = 800)

t13

peak_Profile_Heatmap(peak = files[4:5],
                     upstream = 1000,
                     downstream = 1000,
                     by = c("gene19","geneX"),
                     type = "start_site",
                     TxDb = txdb,nbin = 800)

t14

MingLi-929 avatar Oct 15 '22 10:10 MingLi-929