R/plotReadStats.R

Defines functions plotReadStats

Documented in plotReadStats

#' plotReadStats
#'
#' get read stats from count table generated by STAR aligner
#' @export


plotReadStats <- function(read.counts,
                          conditions,
                          bar_colors = c("#999999", "#0072B2", "#CC79A7", "#009E73", "#E69F00", "#D55E00", "#56B4E9", "#F0E442")){


        col_order <- order(conditions)
        bar_colors <- bar_colors[conditions][col_order]

        ##########################################

        barplot(colSums(read.counts)[col_order], main = "Total Reads", las=2, col = bar_colors, cex.main = 1.33)

        barplot(colSums(read.counts[-1,])[col_order], main = "Mapped Reads", las=2, col = bar_colors, cex.main = 1.33)

        barplot(read.counts[2,][col_order], main = "Multi-mapping Reads", las=2, col = bar_colors, cex.main = 1.33)

        barplot(colSums(read.counts[-1:-4,])[col_order], main = "Genic Reads", las=2, col = bar_colors, cex.main = 1.33)


        # ##########################################
        #
        #
        # barplot(t(t(rbind(read.counts[1,],
        #                   read.counts[2,],
        #                   colSums(read.counts[3:4,]),
        #                   colSums(read.counts[-1:-4,]))) / colSums(read.counts)),
        #         main = "Read Distribution", ylab = "Fraction", las=2)
        #
        # legend("topleft", legend = rev(c(gsub("N_","",rownames(read.counts)[1:3]), "Genic")),
        #        fill = rev(gray.colors(4)), bg="white")
        #
        # ##########################################
}
tschauer/HelpersforDESeq2 documentation built on Nov. 11, 2021, 3:10 a.m.