barplotReadCounts: Stacked barplot of read counts

View source: R/bioinfo_sequences.R

barplotReadCountsR Documentation

Stacked barplot of read counts

Description

Make a stacked barplot, for instance from the output of formatReadCountsPerLane. Default graphical parameters are optimized for few categories (e.g. lanes) but many individuals.

Usage

barplotReadCounts(
  counts,
  xlab = paste0("Individuals (", ncol(counts), ")"),
  ylab = "Number of read pairs",
  main = "Read pairs per individual",
  legend.text = rownames(counts),
  col = 1:nrow(counts),
  lines.h = c(10^5, 10^6, 5 * 10^6),
  mar = c(5, 4.5, 4, 0),
  xlab.line = 3,
  font.lab = 2,
  cex.xtxt = 0.7,
  perc = FALSE,
  inset.x = -0.2
)

Arguments

counts

matrix, with categories (e.g. lanes) in rows and individuals in columns; if colnames is not NULL, they will be used as labels of the x-axis

xlab

a title for the x axis

ylab

a title for the y axis

main

an overall title for the plot

legend.text

see barplot

col

see barplot

lines.h

the y-value(s) for horizontal line(s)

mar

see par

xlab.line

see line from mtext

font.lab

see par

cex.xtxt

see cex from text

perc

if TRUE, plot data from "counts" as percentages (using prop.table), with legend on the topright outside the x-axis range, and columns (of "counts") sorted in the increasing order corresponding of the first row

inset.x

inset distance along the x axis from the margins as a fraction of the plot region

Value

invisible output of barplot

Author(s)

Timothee Flutre

Examples

## Not run: ## make fake data
(x <- matrix(data=c(10,3, 20,0, 21,17, 35,19), nrow=2, ncol=4,
             dimnames=list(c("lane1", "lane2"),
             c("ind1", "ind2", "ind3", "ind4"))))

## plot them
barplotReadCounts(counts=x)
barplotReadCounts(counts=x, perc=TRUE, ylab="Percentage of read pairs",
                  mar=c(5, 4.5, 4, 6))

## End(Not run)

timflutre/rutilstimflutre documentation built on Feb. 7, 2024, 8:17 a.m.