Title: | Mueller's R tools |
---|---|
Description: | Fabian's custom plotting functions and utilities |
Authors: | Fabian Mueller |
Maintainer: | Fabian Mueller <[email protected]> |
License: | GPL-2 |
Version: | 0.9.6 |
Built: | 2025-02-03 06:30:56 UTC |
Source: | https://github.com/demuellae/muRtools |
Wrapper around aggregate
to merge rows of a data frame based on a specified grouping.
Merging is done by either returning the unique value for each group or if multiple different
values exists converting them to character and concatenating by ";"
aggregateDf(df, groupBy)
aggregateDf(df, groupBy)
df |
|
groupBy |
vector whose unique values indicates the grouping of the rows in the data frame |
aggregated data.frame
Fabian Mueller
loads a bed file and converts it to a GRanges object. Note that bed files are 0-based, right-exclusive by definition The output of this function will be 1-based, right inclusive as defined by GRanges.
bed2GRanges(fname, assembly = NA)
bed2GRanges(fname, assembly = NA)
assembly |
genome assembly |
id |
region set id |
a GRanges object containing the region set
reg.fname <- system.file(file.path("extdata","deep_chip_ctrl_regions.hg19.bed"), package = "muRtools") regs <- bed2GRanges(reg.fname)
reg.fname <- system.file(file.path("extdata","deep_chip_ctrl_regions.hg19.bed"), package = "muRtools") regs <- bed2GRanges(reg.fname)
Convert a bed file to bigBed. requires the 'bedToBigBed' tool
bedTobigBed( bedFn, chromSizes, bbFn = paste0(gsub("\\.bed$", "", bedFn), ".bb"), bedToBigBed = "bedToBigBed" )
bedTobigBed( bedFn, chromSizes, bbFn = paste0(gsub("\\.bed$", "", bedFn), ".bb"), bedToBigBed = "bedToBigBed" )
bedFn |
filename of the bed file |
chromSizes |
named vector of chromosome sizes |
bbFn |
filename to save the bigBed file to |
bedToBigBed |
executable of the 'bedToBigBed' tool |
nothing of particular interest
converts camel case to underscores in a (vector of) string(s)
camel2underscore(x)
camel2underscore(x)
a |
string or string vector |
the converted string(s)
underscore2camel("bla_blubb")
underscore2camel("bla_blubb")
Plot a bipartite chord diagram (circular Sankey diagram with 2 categories) for a contingency matrix the values of two matrices
chordDiagramFromContingencyTable( contTab, chordColorByCol = FALSE, cs_rows = colpal.mu.cat, cs_columns = colpal.mu.cat, ... )
chordDiagramFromContingencyTable( contTab, chordColorByCol = FALSE, cs_rows = colpal.mu.cat, cs_columns = colpal.mu.cat, ... )
contTab |
|
chordColorByCol |
color chords by column instead of by row |
cs_rows |
color scheme to use for the rows of the matrix |
cs_columns |
color scheme to use for the rows of the matrix |
... |
passed on to |
nothing of particular interest (include this function while plotting).
Fabian Mueller
# contingency table of air quality quantile by month contTab <- with(airquality, table(cut(Temp, quantile(Temp)), Month)) names(dimnames(contTab))[1] <- "quantile" chordDiagramFromContingencyTable(contTab)
# contingency table of air quality quantile by month contTab <- with(airquality, table(cut(Temp, quantile(Temp)), Month)) names(dimnames(contTab))[1] <- "quantile" chordDiagramFromContingencyTable(contTab)
convert a color from a text string to a hex string (only works with scalars, not on vectors)
col.text.2.hex(ss, alpha = 255)
col.text.2.hex(ss, alpha = 255)
ss |
color string to be transformed |
alpha |
maximum alpha |
a string containing the hex code of the color
col.text.2.hex("dark blue")
col.text.2.hex("dark blue")
transforms a value to a color based on a colorscale and a value scale
colorize.value( val, rng = c(-1, 1), colscheme.col.val = c(gplots::colorpanel(100, "blue", "white"), gplots::colorpanel(100, "white", "red")) )
colorize.value( val, rng = c(-1, 1), colscheme.col.val = c(gplots::colorpanel(100, "blue", "white"), gplots::colorpanel(100, "white", "red")) )
val |
value to be transformed |
rng |
value range |
colscheme.col.val |
Color palette to pick a color from |
color of the value
colorize.value(0.5,rng=c(-1,1), colscheme.col.val=c(colorpanel(100,"blue","white"),colorpanel(100,"white","red")))
colorize.value(0.5,rng=c(-1,1), colscheme.col.val=c(colorpanel(100,"blue","white"),colorpanel(100,"white","red")))
colpal.cb
color blind friendly color palettes (adapted from http://wiki.stdout.org/rcookbook/Graphs/Colors
colpal.cb colpal.bde colpal.nature colpal.mu.cat colpal.iwh.cb01 colpal.solarextra colpals.topo colpal.PhFr.a colpal.miniblaze colpal.corpid colpals.games
colpal.cb colpal.bde colpal.nature colpal.mu.cat colpal.iwh.cb01 colpal.solarextra colpals.topo colpal.PhFr.a colpal.miniblaze colpal.corpid colpals.games
An object of class character
of length 9.
An object of class character
of length 13.
An object of class character
of length 17.
An object of class character
of length 18.
An object of class character
of length 23.
An object of class character
of length 9.
An object of class list
of length 2.
An object of class character
of length 9.
An object of class character
of length 6.
An object of class character
of length 19.
An object of class list
of length 6.
plotColpal(colpal.cb) plotColpal(colpal.bde) plotColpal(colpal.nature) plotColpal(colpal.mu.cat) plotColpal(colpal.iwh.cb01) plotColpal(colpal.solarextra) plotColpal(colpals.topo[["dem_cut"]]) plotColpal(colpal.PhFr.a) plotColpal(colpal.PhFr.a) plotColpal(colpal.corpid) plotColpal(colpals.games[["rollgalaxy"]])
plotColpal(colpal.cb) plotColpal(colpal.bde) plotColpal(colpal.nature) plotColpal(colpal.mu.cat) plotColpal(colpal.iwh.cb01) plotColpal(colpal.solarextra) plotColpal(colpals.topo[["dem_cut"]]) plotColpal(colpal.PhFr.a) plotColpal(colpal.PhFr.a) plotColpal(colpal.corpid) plotColpal(colpals.games[["rollgalaxy"]])
Get a continuous color palette
colpal.cont(n = 3, name = "viridis", ...)
colpal.cont(n = 3, name = "viridis", ...)
n |
number of colors returned |
name |
name of the color palette |
... |
arguments passed to other functions |
a character vector containing n colors
Fabian Mueller
plotColpal(colpal.cont(5, "viridis")) plotColpal(colpal.cont(5, "cb.BrBG")) plotColpal(colpal.cont(9, "solarextra")) plotColpal(colpal.cont(9, "cptcity.schwarzwald_cont")) plotColpal(colpal.cont(9, "cptcity.europe_7")) plotColpal(colpal.cont(9, "cptcity.spain")) plotColpal(colpal.cont(9, "cptcity.nordisk")) plotColpal(colpal.cont(9, "cptcity.cmocean_delta")) plotColpal(colpal.cont(9, "cptcity.colombia")) plotColpal(colpal.cont(9, "cptcity.blue_tan_d14")) plotColpal(colpal.cont(9, "cptcity.arendal_temperature")) plotColpal(colpal.cont(9, "cptcity.jjg_misc_temperature")) plotColpal(colpal.cont(9, "cptcity.jjg_neo10_elem_rain")) plotColpal(colpal.cont(9, "cptcity.es_vintage_57")) plotColpal(colpal.cont(9, "cptcity.es_skywalker_02"))
plotColpal(colpal.cont(5, "viridis")) plotColpal(colpal.cont(5, "cb.BrBG")) plotColpal(colpal.cont(9, "solarextra")) plotColpal(colpal.cont(9, "cptcity.schwarzwald_cont")) plotColpal(colpal.cont(9, "cptcity.europe_7")) plotColpal(colpal.cont(9, "cptcity.spain")) plotColpal(colpal.cont(9, "cptcity.nordisk")) plotColpal(colpal.cont(9, "cptcity.cmocean_delta")) plotColpal(colpal.cont(9, "cptcity.colombia")) plotColpal(colpal.cont(9, "cptcity.blue_tan_d14")) plotColpal(colpal.cont(9, "cptcity.arendal_temperature")) plotColpal(colpal.cont(9, "cptcity.jjg_misc_temperature")) plotColpal(colpal.cont(9, "cptcity.jjg_neo10_elem_rain")) plotColpal(colpal.cont(9, "cptcity.es_vintage_57")) plotColpal(colpal.cont(9, "cptcity.es_skywalker_02"))
Named vectors of colors for different modifications
colpal.histone
Histone modifications
colpal.histone colpal.histone.ihec colgrad.methylation.rb colgrad.methylation.yb
colpal.histone colpal.histone.ihec colgrad.methylation.rb colgrad.methylation.yb
An object of class character
of length 10.
An object of class character
of length 8.
An object of class character
of length 3.
An object of class character
of length 3.
library(gplots) pie(rep(1,length(colpal.histone)), labels=names(colpal.histone), col=colpal.histone) library(gplots) pie(rep(1,length(colpal.histone.ihec)), labels=names(colpal.histone.ihec), col=colpal.histone.ihec) library(plotrix) cp <- colorpanel(100,colgrad.methylation.rb["low"],colgrad.methylation.rb["mid"],colgrad.methylation.rb["high"]) plot.new() gradient.rect(0,0,1,1,col=cp,nslices=length(cp),gradient="x",border=NA) library(plotrix) cp <- colorpanel(100,colgrad.methylation.yb["low"],colgrad.methylation.yb["mid"],colgrad.methylation.yb["high"]) plot.new() gradient.rect(0,0,1,1,col=cp,nslices=length(cp),gradient="x",border=NA)
library(gplots) pie(rep(1,length(colpal.histone)), labels=names(colpal.histone), col=colpal.histone) library(gplots) pie(rep(1,length(colpal.histone.ihec)), labels=names(colpal.histone.ihec), col=colpal.histone.ihec) library(plotrix) cp <- colorpanel(100,colgrad.methylation.rb["low"],colgrad.methylation.rb["mid"],colgrad.methylation.rb["high"]) plot.new() gradient.rect(0,0,1,1,col=cp,nslices=length(cp),gradient="x",border=NA) library(plotrix) cp <- colorpanel(100,colgrad.methylation.yb["low"],colgrad.methylation.yb["mid"],colgrad.methylation.yb["high"]) plot.new() gradient.rect(0,0,1,1,col=cp,nslices=length(cp),gradient="x",border=NA)
get a list of all combinations of vectors. Basically a wrapper around expand.grid
combinationList(...)
combinationList(...)
... |
vectors of elements. Ideally named |
a list containing all combinations of elements in the input. Each element contains a unique combination
combinationList(a=letters[1:5], A=LETTERS[1:3], i=1:4)
combinationList(a=letters[1:5], A=LETTERS[1:3], i=1:4)
Methods for recognizing histone modifications from strings
containsHistoneModStr(s) getHistoneFromHistoneModStr(s) getAaTypeFromHistoneModStr(s) getAaPosFromHistoneModStr(s) getModFromHistoneModStr(s) normalizeHistoneModStr(s) matchHistoneModStr(s1, s2)
containsHistoneModStr(s) getHistoneFromHistoneModStr(s) getAaTypeFromHistoneModStr(s) getAaPosFromHistoneModStr(s) getModFromHistoneModStr(s) normalizeHistoneModStr(s) matchHistoneModStr(s1, s2)
s |
a string |
s1 |
a string |
s2 |
a string
|
s1 <- "H3K4me3" s2 <- "h3k04ME3" s3 <- "blubb5A27me3" s4 <- "h3k27ac" containsHistoneModStr(s1) containsHistoneModStr(s3) containsHistoneModStr(s4) getHistoneFromHistoneModStr(s1) getAaTypeFromHistoneModStr(s1) getAaPosFromHistoneModStr(s1) getModFromHistoneModStr(s1) normalizeHistoneModStr(s1) normalizeHistoneModStr(c(s1,s2,s3,s4)) matchHistoneModStr(s1,s2) matchHistoneModStr(s1,s4)
s1 <- "H3K4me3" s2 <- "h3k04ME3" s3 <- "blubb5A27me3" s4 <- "h3k27ac" containsHistoneModStr(s1) containsHistoneModStr(s3) containsHistoneModStr(s4) getHistoneFromHistoneModStr(s1) getAaTypeFromHistoneModStr(s1) getAaPosFromHistoneModStr(s1) getModFromHistoneModStr(s1) normalizeHistoneModStr(s1) normalizeHistoneModStr(c(s1,s2,s3,s4)) matchHistoneModStr(s1,s2) matchHistoneModStr(s1,s4)
Fast counting of pairwise overlaps between two lists of region sets
countPairwiseOverlaps(grl1, grl2, ...)
countPairwiseOverlaps(grl1, grl2, ...)
grl1 |
list of |
grl2 |
list of |
... |
arguments passed on to |
an integer matrix containing pairwise overlaps between elements in grl1
and grl1
Creates a density scatterplot highlighting points in sparsely populated plot regions as well as points marked as special in a seperate color
create.densityScatter( df2p, is.special = NULL, dens.subsample = FALSE, dens.special = TRUE, sparse.points = 0.01, dens.n = 100, add.text.cor = FALSE )
create.densityScatter( df2p, is.special = NULL, dens.subsample = FALSE, dens.special = TRUE, sparse.points = 0.01, dens.n = 100, add.text.cor = FALSE )
df2p |
|
is.special |
boolean vector of length equal to the number of rows in |
dens.subsample |
if the number of points exceeds this number, subsample the number of points for the density estimation to that number. Any non-numeric value disables subsampling. |
dens.special |
Flag indicating whether the points of the special population should be colored according to their density |
sparse.points |
Either percentage ( |
dens.n |
passed on to |
add.text.cor |
flag indicating whether a text token with the correlation coefficient should be included in the lower right corner of the plot |
ggplot
object
Fabian Mueller (RnBeads)
d <- data.frame(x=rnorm(1000),y=rnorm(1000)) s <- rep(FALSE,1000) s[sample(1:length(s),100)] <- TRUE create.densityScatter(d,s)
d <- data.frame(x=rnorm(1000),y=rnorm(1000)) s <- rep(FALSE,1000) s[sample(1:length(s),100)] <- TRUE create.densityScatter(d,s)
Rank the points accordind to density of the region they fall in. Densities are computed
as Kernel Density estimates. The method and parameters are implemented in analogy to
grDevices::densCols
densRanks(x, y = NULL, nbin = 128, bandwidth)
densRanks(x, y = NULL, nbin = 128, bandwidth)
x |
x-coordinate |
y |
y-coordinate |
nbin |
number of bins |
bandwidth |
bandwidth |
Fabian Mueller (RnBeads)
Converts a data.frame
that defines genomic regions to object of type GRanges
.
df2granges( df, ids = rownames(df), chrom.col = 1L, start.col = 2L, end.col = 3L, strand.col = NULL, coord.format = "B1RI", assembly = NULL, doSort = FALSE, adjNumChromNames = FALSE )
df2granges( df, ids = rownames(df), chrom.col = 1L, start.col = 2L, end.col = 3L, strand.col = NULL, coord.format = "B1RI", assembly = NULL, doSort = FALSE, adjNumChromNames = FALSE )
df |
Table defining genomic regions. |
ids |
Region names (identifiers) as a |
chrom.col |
Column name or index that lists the chromosome names. |
start.col |
Column name or index that lists the start positions of the regions. |
end.col |
Column name or index that lists the end positions of the regions. |
strand.col |
Column name or index that lists the strands on which the regions are located. Set this to
|
coord.format |
Coordinate format |
assembly |
Genome assembly of interest. See |
doSort |
Should the resulting table be sorted |
adjNumChromNames |
Should numeric chromosome names be adjusted for by adding the prefix "chr". Additionally chrMT becomes chrM. useful for converting GRC identifiers to NCBI identifiers |
GRanges
object encapsulating of regions included in df
.
As GRanges, the coordinates will be 1-based right-inclusive.
Columns other that the ones listed as parameters in this function are included as elementMetadata.
df <- data.frame(chrom=c(rep("chr5", 7), rep("chr21", 3)), start=1:10, end=seq(20, by=10, length.out=10), strand=rep(c("+","+", "-", "*"), length.out=10), letter=letters[1:10], score=rnorm(10)) df df2granges(df, assembly="GRCh38_chr")
df <- data.frame(chrom=c(rep("chr5", 7), rep("chr21", 3)), start=1:10, end=seq(20, by=10, length.out=10), strand=rep(c("+","+", "-", "*"), length.out=10), letter=letters[1:10], score=rnorm(10)) df df2granges(df, assembly="GRCh38_chr")
Plot a heatmap in which each cell is subdivided into a lower-left and upper-right triangle representing the values of two matrices
diagDivCellHeatmap( ml, mr, col.l = NULL, col.r = NULL, name.l = "Lower left", name.r = "Upper right", ... )
diagDivCellHeatmap( ml, mr, col.l = NULL, col.r = NULL, name.l = "Lower left", name.r = "Upper right", ... )
ml |
the first value matrix (will be the left-lower diagonal in the cells of the resulting heatmap) |
mr |
the second value matrix (will be the right-upper diagonal in the cells of the resulting heatmap) |
col.l |
color scheme for the left-lower diagonal matrix. Should be generated by |
col.r |
color scheme for the upper-right diagonal matrix. Should be generated by |
name.l |
Name for the lower-left submatrix |
name.r |
Name for the upper-right submatrix |
... |
parameters passed on to |
a ComplexHeatmap::Heatmap
object containing the heatmap
Fabian Mueller
m1 <- matrix(rnorm(100, mean=0), ncol=10) m2 <- matrix(rnorm(100, mean=2), ncol=10) rownames(m1) <- rownames(m2) <- colnames(m1) <- colnames(m2) <- paste0("Idx", 1:10) diagDivCellHeatmap(m1, m2, cluster_rows=FALSE, cluster_columns=FALSE) cres <- as.hclust(muRtools::getClusteringDendrogram(m1, distMethod="euclidean", linkMethod="ward.D", corMethod="pearson")) diagDivCellHeatmap(m1, m2, cluster_rows=cres, cluster_columns=cres)
m1 <- matrix(rnorm(100, mean=0), ncol=10) m2 <- matrix(rnorm(100, mean=2), ncol=10) rownames(m1) <- rownames(m2) <- colnames(m1) <- colnames(m2) <- paste0("Idx", 1:10) diagDivCellHeatmap(m1, m2, cluster_rows=FALSE, cluster_columns=FALSE) cres <- as.hclust(muRtools::getClusteringDendrogram(m1, distMethod="euclidean", linkMethod="ward.D", corMethod="pearson")) diagDivCellHeatmap(m1, m2, cluster_rows=cres, cluster_columns=cres)
Plot a diagonally divided heatmap u
diagDivHeatmap( ml, mr, col.l = NULL, col.r = NULL, name.l = "Lower left", name.r = "Upper right", cluster = FALSE, cell.val.text = FALSE, cell.val.text.round = 2, ... )
diagDivHeatmap( ml, mr, col.l = NULL, col.r = NULL, name.l = "Lower left", name.r = "Upper right", cluster = FALSE, cell.val.text = FALSE, cell.val.text.round = 2, ... )
ml |
the first value matrix (the left-lower diagonal matrix will be in the result) |
mr |
the first value matrix (the right-upper diagonal matrix will be in the result) |
col.l |
color scheme for the left-lower diagonal matrix. Should be generated by |
col.r |
color scheme for the upper-right diagonal matrix. Should be generated by |
name.l |
Name for the lower-left submatrix |
name.r |
Name for the upper-right submatrix |
cluster |
logical or clustering object. will be passed to the |
cell.val.text |
logical indicating whether the cells value should be added as text |
cell.val.text.round |
if the cell value is numeric, the number of digits to which the cell text is rounded |
... |
parameters passed on to |
a ComplexHeatmap::Heatmap
object containing the heatmap
Fabian Mueller
m1 <- matrix(rnorm(100, mean=0), ncol=10) m2 <- matrix(rnorm(100, mean=2), ncol=10) rownames(m1) <- rownames(m2) <- colnames(m1) <- colnames(m2) <- paste0("Idx", 1:10) diagDivHeatmap(m1, m2) diagDivHeatmap(m1, m2, cell.val.text=TRUE, cell.val.text.round=3) cres <- as.hclust(muRtools::getClusteringDendrogram(m1, distMethod="euclidean", linkMethod="ward.D", corMethod="pearson")) diagDivHeatmap(m1, m2, cluster=cres, cell.val.text=TRUE, cell.val.text.round=2)
m1 <- matrix(rnorm(100, mean=0), ncol=10) m2 <- matrix(rnorm(100, mean=2), ncol=10) rownames(m1) <- rownames(m2) <- colnames(m1) <- colnames(m2) <- paste0("Idx", 1:10) diagDivHeatmap(m1, m2) diagDivHeatmap(m1, m2, cell.val.text=TRUE, cell.val.text.round=3) cres <- as.hclust(muRtools::getClusteringDendrogram(m1, distMethod="euclidean", linkMethod="ward.D", corMethod="pearson")) diagDivHeatmap(m1, m2, cluster=cres, cell.val.text=TRUE, cell.val.text.round=2)
Compute a distance matrix based on 1-corelation
dist.correlation(x, ...)
dist.correlation(x, ...)
x |
a matrix on which the distances should be computed |
... |
parameters passed on to |
a distance matrix
Fabian Mueller
Downloading prepared LOLA DBs from server
downloadLolaDbs(dest, dbs = c("LOLACore"))
downloadLolaDbs(dest, dbs = c("LOLACore"))
dest |
destination directory |
dbs |
vector of names of LOLA DBs to be downloaded. Currently 'LOLACore' and 'LOLAExt' are supported |
Requires a stable internet connection. Could take a while depending on the size of the database and the internet connection
a list containing vectors of directory names for each available genome assembly
Fabian Mueller
lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore")
lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore")
given the ENCODE controlled vocabulary file, retrieves a table characterizing the ENCODE cells
get.encode.cell.table( cvFile = "http://hgdownload.cse.ucsc.edu/goldenPath/encodeDCC/cv.ra" )
get.encode.cell.table( cvFile = "http://hgdownload.cse.ucsc.edu/goldenPath/encodeDCC/cv.ra" )
cvFile |
the file location for the ENCODE controlled vocabulary file. Defaults to the one provided by ENCODE |
a table containing ENCODE cell annotations
ect <- get.encode.cell.table()
ect <- get.encode.cell.table()
Create a GRangesList
with element annotation by downloading the corresponding GTF file from Gencode
getAnnotGrl.gencode(name)
getAnnotGrl.gencode(name)
name |
gencode identifier. Currently supported are: "gencode.v27", "gencode.v19", "gencode.vM16", "gencode.vM1" |
GRangesList
object with annotated elements for each element type (genes, transcripts, exons, ...)
Fabian Mueller
Test associations of annotations with principal components (PCA)
getAssocTestRes.pca(X, ph, nComp = 10, nPerm = 1000)
getAssocTestRes.pca(X, ph, nComp = 10, nPerm = 1000)
X |
A matrix on which the dimension reduction is to be performed. Alternatively, it can be a matrix of PC coordinates computed by |
ph |
annotation table for the datapoints. The columns of this table will be used to test associations with the PCs.
Should be a |
nComp |
number of PCs to be considered |
nPerm |
number of permutation tests to be conducted if an annotation in |
A nested list of tested associations one element for each column in ph
(1st level), each PC (2nd level).
Each element is again a list with the name of the test being used (test
), the test statistic (statistic
) and p-value (pvalue
)
Fabian Mueller
retrieve or guess cell types from a LOLA DB object
getCellTypesFromLolaDb(lolaDb)
getCellTypesFromLolaDb(lolaDb)
lolaDb |
LOLA DB object as returned by |
character vector with cell types
Fabian Mueller
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]]) getCellTypesFromLolaDb(lolaDb)
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]]) getCellTypesFromLolaDb(lolaDb)
Get a clustering dendrogram using hierarchical clustering (wrapper)
getClusteringDendrogram( X, samplesOrdered = colnames(X), distMethod = "cor", linkMethod = "ward.D", corMethod = "pearson" )
getClusteringDendrogram( X, samplesOrdered = colnames(X), distMethod = "cor", linkMethod = "ward.D", corMethod = "pearson" )
X |
A matrix for which the sample clustering dendrogram should be computed. Samples correspond to columns and features correspond to rows.
Alternatively, |
samplesOrdered |
character vector specifying the preferred order of samples |
distMethod |
distance metric to be used for clusteing. must be either "cor" or a valid distance method for |
linkMethod |
linkage method (see |
corMethod |
method for computing correlation coefficients. Only relevant if |
clustering dendrogram (dendrogram
object)
Fabian Mueller
Retrieve a color function mapping values to colors. Uses and modeled after circlize::colorRamp2
.
getColorFun(x, colPal = NULL)
getColorFun(x, colPal = NULL)
x |
vector or matrix including potential values |
colPal |
a color palette to be used. Should be a character vector specifying colors. can be named if specific colors should be used for specific values |
a function mapping a value to a corresponding color character string
Fabian Mueller
randomLetters <- sample(letters[1:6], 50, replace=TRUE) cf_cat <- getColorFun(randomLetters) cf_cat("f") cf_cat("x") # NA cf_cat2 <- getColorFun(randomLetters, colPal=c(a="#009FE3", b="#DE7E00", c="#8EC041", d="#FFCC00", e="#951B81", f="#BE1716")) cf_num <- getColorFun(runif(50)) cf_num2 <- getColorFun(runif(50), colpal.cont(9, "cb.YlOrRd"))) cf_num2(0.5)
randomLetters <- sample(letters[1:6], 50, replace=TRUE) cf_cat <- getColorFun(randomLetters) cf_cat("f") cf_cat("x") # NA cf_cat2 <- getColorFun(randomLetters, colPal=c(a="#009FE3", b="#DE7E00", c="#8EC041", d="#FFCC00", e="#951B81", f="#BE1716")) cf_num <- getColorFun(runif(50)) cf_num2 <- getColorFun(runif(50), colpal.cont(9, "cb.YlOrRd"))) cf_num2(0.5)
Get analysis configuration object from a JSON file. Automatically runs parsers for config elements specified in the '.MU_ANA_CONFIG' section of the JSON file
getConfig(cfgFn, anaName, addDirs = TRUE)
getConfig(cfgFn, anaName, addDirs = TRUE)
cfgFn |
JSON file name |
anaName |
name of the analysis to be conducted |
addDirs |
should the analysis directories be created and added to the object |
an S3 object containing analysis config elements
Fabian Mueller
Get dimension reduction coordinates (Multidimensional Scaling)
getDimRedCoords.mds(X, distMethod = "euclidean")
getDimRedCoords.mds(X, distMethod = "euclidean")
X |
A matrix on which the dimension reduction is to be performed |
distMethod |
distance metric to be employed |
a matrix containing two columns for the reduced dimensions and the same number of
rows as X
Fabian Mueller
Get dimension reduction coordinates (PCA)
getDimRedCoords.pca(X, components = c(1, 2), method = "prcomp", ...)
getDimRedCoords.pca(X, components = c(1, 2), method = "prcomp", ...)
X |
A matrix on which the dimension reduction is to be performed |
components |
principal component to be returned |
method |
Method/package to be used for computing principal components. Currently |
... |
other arguments passed on to the PCA method |
a matrix containing two columns for the reduced dimensions and the same number of
rows as X
Fabian Mueller
Get dimension reduction coordinates (t-SNE)
getDimRedCoords.tsne(X, distMethod = "euclidean", dims = c(1, 2))
getDimRedCoords.tsne(X, distMethod = "euclidean", dims = c(1, 2))
X |
A matrix on which the dimension reduction is to be performed |
distMethod |
distance metric to be employed |
dims |
dimensions to return from the reduction |
a matrix containing two columns for the reduced dimensions and the same number of
rows as X
Fabian Mueller
Get dimension reduction coordinates using the UMAP method
getDimRedCoords.umap(X, distMethod = "euclidean", dims = c(1, 2), ...)
getDimRedCoords.umap(X, distMethod = "euclidean", dims = c(1, 2), ...)
X |
A matrix on which the dimension reduction is to be performed |
distMethod |
distance metric to be employed |
dims |
dimensions to return from the reduction |
... |
parameters passed on to |
a matrix containing two columns for the reduced dimensions and the same number of
rows as X
Fabian Mueller
Generate a plot from dimension reduction coordinates
getDimRedPlot( coords, annot = NULL, colorCol = NULL, shapeCol = NULL, colScheme = "[auto]", ptSize = 3, addLabels = FALSE, addDensity = FALSE, addVoronoi = FALSE, annot.text = NULL, orderCol = NULL, facetCols = NULL )
getDimRedPlot( coords, annot = NULL, colorCol = NULL, shapeCol = NULL, colScheme = "[auto]", ptSize = 3, addLabels = FALSE, addDensity = FALSE, addVoronoi = FALSE, annot.text = NULL, orderCol = NULL, facetCols = NULL )
coords |
dimension reduction coordinates |
annot |
annotation matrix with the same number of rows as |
colorCol |
name or index in the annotation matrix ( |
shapeCol |
name or index in the annotation matrix ( |
colScheme |
color sheme to be used in coloring the points. can be a character vector with the supplied colors. Alternatively, if it is a one-element character vector |
ptSize |
size of the points in the scatterplot |
addLabels |
should observation labels be added to each point |
addDensity |
should Gaussian Kernel density estimation be performed and the contour lines plotted for each color group |
addVoronoi |
should a Voronoi tessalation grid (based on |
annot.text |
optional text to be added in the lower right corner of the plot |
orderCol |
name or index in the annotation matrix ( |
facetCols |
name (string) of columns to be used for faceting the resulting plot. Each facet will contain all the points not in the facet as grey points. |
a ggplot2
object containing the dimension reduction plot
Fabian Mueller
df <- data.frame( x = c(rnorm(20, mean=0, sd=0.2), rnorm(10, mean=1, sd=0.4), rnorm(15, mean=1, sd=0.2)), y = c(rnorm(20, mean=0, sd=0.2), rnorm(10, mean=1, sd=0.4), rnorm(15, mean=0.5, sd=0.3)), group = rep(c("group1", "group2", "group3"), times=c(20,10,15)), stringsAsFactors=FALSE ) getDimRedPlot(df[,c("x", "y")], annot=df[,c("group"), drop=FALSE], colorCol="group") getDimRedPlot(df[,c("x", "y")], annot=df[,c("group"), drop=FALSE], colorCol="group", addDensity=TRUE)
df <- data.frame( x = c(rnorm(20, mean=0, sd=0.2), rnorm(10, mean=1, sd=0.4), rnorm(15, mean=1, sd=0.2)), y = c(rnorm(20, mean=0, sd=0.2), rnorm(10, mean=1, sd=0.4), rnorm(15, mean=0.5, sd=0.3)), group = rep(c("group1", "group2", "group3"), times=c(20,10,15)), stringsAsFactors=FALSE ) getDimRedPlot(df[,c("x", "y")], annot=df[,c("group"), drop=FALSE], colorCol="group") getDimRedPlot(df[,c("x", "y")], annot=df[,c("group"), drop=FALSE], colorCol="group", addDensity=TRUE)
Get a mapping (e.g. of identifiers) and automatically select the correct AnnotationDbi
database for a given
assembly
getGeneAnnotMap(assembly, from = "ENSEMBL", to = "SYMBOL", multiMap = "paste")
getGeneAnnotMap(assembly, from = "ENSEMBL", to = "SYMBOL", multiMap = "paste")
assembly |
character string specifying the assembly |
from |
the column name that will be used as the key for the resulting map |
to |
the column name that will be used as the result for the resulting map |
multiMap |
character string specifying what to do if multiple mappings are found for a key
by default ( |
a named vector (or list depending on how the multiMap
argument is chosen) providing a mapping
Fabian Mueller
retrieve the full genome as GRanges object
getGenomeGr(assembly, ...)
getGenomeGr(assembly, ...)
assembly |
assembly |
... |
other arguments passed on to |
GRanges
object
retrieve the appropriate BSgenome
for an assembly string
getGenomeObject(assembly, adjChrNames = TRUE)
getGenomeObject(assembly, adjChrNames = TRUE)
assembly |
string specifying the assembly |
adjChrNames |
should the prefix "chr" be added to main chromosomes if not already present and chrMT be renamed to chrM? |
BSgenome
object
Get a hash string, i.e. a string unlikely to occur again
getHashString(pattern = "", useDate = TRUE)
getHashString(pattern = "", useDate = TRUE)
pattern |
a prefix that will be used in the returned hash string |
useDate |
Should the current time and date be used in the hash string to make it even more unique |
a character string unlikely to occur again
Fabian Mueller
getHashString()
getHashString()
get human readable names from a LOLA DB object
getNamesFromLolaDb(lolaDb, addCollectionNames = FALSE, addDbId = TRUE)
getNamesFromLolaDb(lolaDb, addCollectionNames = FALSE, addDbId = TRUE)
lolaDb |
LOLA DB object as returned by |
addCollectionNames |
attach the name of the collection to the name |
addDbId |
attach the index of the item in the LOLA DB object to the name |
character vector with human readable names
Fabian Mueller
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]]) getNamesFromLolaDb(lolaDb)
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]]) getNamesFromLolaDb(lolaDb)
Get point density of points in 2 dimensions. Code from http://slowkow.com/notes/ggplot2-color-by-density/
getPointDensity(x, y, n = 100)
getPointDensity(x, y, n = 100)
x |
A numeric vector. |
y |
A numeric vector. |
n |
Create a square n by n grid to compute density. |
The density within each square
retrieves custom region sets by id
getRegionSet(id, assembly)
getRegionSet(id, assembly)
id |
region set id |
assembly |
genome assembly |
a GRanges object containing the region set
regs <- getRegionSet("deep_chip_ctrl_regions","hg19")
regs <- getRegionSet("deep_chip_ctrl_regions","hg19")
Get analysis configuration object from a JSON file. Automatically runs parsers for config elements specified in the '.MU_ANA_CONFIG' section of the JSON file
getRelatedAnaDirFromConfig(cfg, anaName, anaVersion = cfg[[".anaVersion"]])
getRelatedAnaDirFromConfig(cfg, anaName, anaVersion = cfg[[".anaVersion"]])
cfg |
configuration object as returned by |
anaName |
name of the analysis |
anaVersion |
version of the analysis. If |
path of the related analysis directory
Fabian Mueller
retrieve chromosomes/contigs and their sequence lengths for known assemblies
getSeqlengths4assembly(assembly, onlyMainChrs = FALSE, adjChrNames = TRUE)
getSeqlengths4assembly(assembly, onlyMainChrs = FALSE, adjChrNames = TRUE)
assembly |
assembly |
onlyMainChrs |
should only main chromosomes, i.e. chr[1-N] + chr[XYM] be returned (e.g. not ChrUn*, *_random, ...) |
adjChrNames |
should the prefix "chr" be added to main chromosomes if not already present and chrMT be renamed to chrM? |
named vector of chromosomes/contigs and sequence lengths
retrieve or guess the target from a LOLA DB object. Here, target typically refers to antibodies for ChIP-seq experiments, but could also refer to other annotations (e.g. motifs in TF motif databases, annotation according to UCSC features etc.)
getTargetFromLolaDb(lolaDb)
getTargetFromLolaDb(lolaDb)
lolaDb |
LOLA DB object as returned by |
character vector with targets
Fabian Mueller
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]]) getTargetFromLolaDb(lolaDb)
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]]) getTargetFromLolaDb(lolaDb)
Get a GRanges object of tiling regions for a specified genome assembly
getTilingRegions(assembly, width = 1000L, ...)
getTilingRegions(assembly, width = 1000L, ...)
assembly |
assembly |
width |
tiling window size |
... |
arguments passed on to |
GRanges object containing tiling windows
Create a TxDb
object by downloading the corresponding GTF file from Gencode
getTxDb.gencode(name)
getTxDb.gencode(name)
name |
gencode identifier. Currently supported are: "gencode.v27", "gencode.v19", "gencode.vM16", "gencode.vM1" |
TxDb
object
Fabian Mueller
Automatical color scales for values for ggplots
ggAutoColorScale(x, method = "color", symmetric = TRUE)
ggAutoColorScale(x, method = "color", symmetric = TRUE)
x |
vector of values |
method |
method for scaling: |
symmetric |
treat numeric values as symmetric. If there are values smaller and larger than 0, a diverging color scheme will be applied |
the theme structure
dframe.num.pos <- data.frame(x=runif(100),y=runif(100)) ggplot(dframe.num.pos, aes(x=x,y=y, color=x)) + geom_point() + ggAutoColorScale(dframe.num.pos[,"x"]) dframe.num.sym <- data.frame(x=rnorm(100),y=rnorm(100)) ggplot(dframe.num.sym, aes(x=x,y=y, color=x)) + geom_point() + ggAutoColorScale(dframe.num.sym[,"x"]) dframe.num.sym.lab <- data.frame(x=rnorm(100),y=rnorm(100), lab=sample(c("A", "B", "C", "D"), 100, replace=TRUE)) ggplot(dframe.num.sym.lab, aes(x=x,y=y, color=lab)) + geom_point() + ggAutoColorScale(dframe.num.sym.lab[,"lab"])
dframe.num.pos <- data.frame(x=runif(100),y=runif(100)) ggplot(dframe.num.pos, aes(x=x,y=y, color=x)) + geom_point() + ggAutoColorScale(dframe.num.pos[,"x"]) dframe.num.sym <- data.frame(x=rnorm(100),y=rnorm(100)) ggplot(dframe.num.sym, aes(x=x,y=y, color=x)) + geom_point() + ggAutoColorScale(dframe.num.sym[,"x"]) dframe.num.sym.lab <- data.frame(x=rnorm(100),y=rnorm(100), lab=sample(c("A", "B", "C", "D"), 100, replace=TRUE)) ggplot(dframe.num.sym.lab, aes(x=x,y=y, color=lab)) + geom_point() + ggAutoColorScale(dframe.num.sym.lab[,"lab"])
Creates a plot, using ggplot2, with a single text message.
ggMessagePlot(txt)
ggMessagePlot(txt)
txt |
Text to be plotted. |
The newly initialized ggplot
instance.
ggMessagePlot("Missing data")
ggMessagePlot("Missing data")
Distribution plot combining violin and boxplot using ggplot2
ggplot2.distr(x, fillColor = "#676D8D")
ggplot2.distr(x, fillColor = "#676D8D")
x |
vector of values whose distribution is to be plottet |
fillColor |
color to be used to fill the violin |
the ggplot2 object (can be extended for plotting)
x <- rnorm(1000) ggplot2.distr(x)
x <- rnorm(1000) ggplot2.distr(x)
converts a matrix or dataframe into a ggplot2 object for subsequent plotting.
ggplot2.heatmap(mm, add.text = FALSE)
ggplot2.heatmap(mm, add.text = FALSE)
mm |
matrix or dataframe to be plottet as heatmap |
add.text |
logical. should the cells be labelled with the values |
the ggplot2 object (can be extended for plotting)
ggplot2.heatmap(airquality[1:15,],add.text=TRUE) + scale_fill_gradient(low = "red",high = "steelblue"))
ggplot2.heatmap(airquality[1:15,],add.text=TRUE) + scale_fill_gradient(low = "red",high = "steelblue"))
Wrapper around ggsave that has default values for parameters fitting for embedding plots into my documents
ggsave4doc( fn, plot = last_plot(), width = 192, height = 192, units = "mm", family = "Helvetica", dimPreset = NULL, useDingbats = FALSE, ... )
ggsave4doc( fn, plot = last_plot(), width = 192, height = 192, units = "mm", family = "Helvetica", dimPreset = NULL, useDingbats = FALSE, ... )
fn |
file name |
plot |
see |
width |
see |
height |
see |
units |
see |
family |
see |
dimPreset |
presets for figure dimensions. Possible values are |
useDingbats |
see |
... |
see |
result of ggsave
command
Wrapper for quickly saving plot to temporary file
ggtemp( plot = last_plot(), fn = paste0("~/tmp_work/", getHashString("ggplot"), ".pdf"), ... )
ggtemp( plot = last_plot(), fn = paste0("~/tmp_work/", getHashString("ggplot"), ".pdf"), ... )
plot |
see |
fn |
file name |
... |
see |
result of ggsave
command
Perform Gene Ontology (GO) enrichment using the topGO
package
goEnrichment( qids, uids, ontology = "BP", idType = "ensembl", assembly = "org.Hs.eg.db", algorithm = "weight01" )
goEnrichment( qids, uids, ontology = "BP", idType = "ensembl", assembly = "org.Hs.eg.db", algorithm = "weight01" )
qids |
character vector of query gene IDs |
uids |
character vector of universe gene IDs |
ontology |
character specifying the ontology to use (default: |
idType |
character specifying which universe the gene IDs come from (default: |
assembly |
character specifying the genome to use. Can either be the name of the package to be used for mapping the identifiers (e.g. |
algorithm |
algorithm employed by |
a list (S3 class) object containing:
- $tgData
: the used topGOdata
object
- $resultObj
: the resulting topGOresult
object
- $table
: a summary table of statistics for each GO term
Fabian Mueller
Save a GRanges object to a bed file
granges2bed( gr, fn, score = NULL, addAnnotCols = FALSE, colNames = FALSE, doSort = TRUE, bedgraph = FALSE, bigBed = FALSE, tabix = FALSE, strandCharNA = ".", coordOnly = FALSE )
granges2bed( gr, fn, score = NULL, addAnnotCols = FALSE, colNames = FALSE, doSort = TRUE, bedgraph = FALSE, bigBed = FALSE, tabix = FALSE, strandCharNA = ".", coordOnly = FALSE )
gr |
GRanges object |
fn |
filename to save bed file to |
addAnnotCols |
add the columns stored in elementMetadata of GRanges |
colNames |
add column names |
doSort |
sort the regions before writing the output |
bedgraph |
export to bedgraph instead of bed |
bigBed |
also save as bigbed file. Requires that the GRanges object has chromosome sizes stored. |
tabix |
compress and index by tabix |
strandCharNA |
character to be used if strand is NA, '*' or '.' |
coordOnly |
output only the coordinates and strand information (only taken into account if |
sc |
score vector or column in elementMetadata of GRanges |
(invisibly) the written results as a data.frame
Save a GRanges object to a bed file which can be displayed by IGV
granges2bed.igv( gr, fn, trackName = NULL, scoreCol = NULL, na.rm = FALSE, nameCol = NULL, col.cat = colpal.bde, col.cont = c("#EDF8B1", "#41B6C4", "#081D58"), col.na = "#bdbdbd", col.range = NULL, doSort = TRUE )
granges2bed.igv( gr, fn, trackName = NULL, scoreCol = NULL, na.rm = FALSE, nameCol = NULL, col.cat = colpal.bde, col.cont = c("#EDF8B1", "#41B6C4", "#081D58"), col.na = "#bdbdbd", col.range = NULL, doSort = TRUE )
gr |
GRanges object |
fn |
filename to save bed file to |
trackName |
track name to be displayed |
scoreCol |
the score column (in the GRanges elementMetadata) that is optionally used for coloring |
na.rm |
flag indicating whether items with NA score should be removed |
nameCol |
the name column (in the GRanges elementMetadata) that is used for labelling the items |
col.cat |
color panel for coloring categorical scores |
col.cont |
color panel for coloring numerical scores |
col.na |
color used for NA scores |
col.range |
vector of length 2 indicating the range of scores for the color scales to be applied (continuous scores only) |
doSort |
sort the regions before writing the output |
invisibly, the resulting data frame containing the bed file columns
Save a GRanges object to a IGV file
granges2igv( gr, fn, addStrand = FALSE, addAnnotCols = TRUE, doSort = TRUE, toTDF = FALSE )
granges2igv( gr, fn, addStrand = FALSE, addAnnotCols = TRUE, doSort = TRUE, toTDF = FALSE )
gr |
GRanges object |
fn |
filename to save IGV file to |
addAnnotCols |
add the columns stored in elementMetadata of GRanges |
doSort |
sort the regions before writing the output |
toTDF |
convert to TDF file. Requires that "igvtools" is executable from the current path |
sc |
score vector or column in elementMetadata of GRanges |
result of writing the table (see write.table
)
get gene annotation for a GRanges
object using a RegionSetDB
region database object by linking to the nearest gene
grGeneAnnot( gr, rsdb, geneSetName = "genes_protein_coding", geneSetCollection = "Gencode", maxDist = 1e+05 )
grGeneAnnot( gr, rsdb, geneSetName = "genes_protein_coding", geneSetCollection = "Gencode", maxDist = 1e+05 )
gr |
|
rsdb |
|
geneSetName |
Name of the region set containng gene annotation in the |
geneSetCollection |
Name of the region set collection containng gene annotation in the |
maxDist |
maximum distance for matching to nearest gene |
data.frame
containing information on the nearest gene for each element in gr
Converts coordinates of a GRanges object to target genome assembly. Wraps around rtracklayer::liftOver and automatically downloads and selects the correct chain file
grLiftOver(gr, targetAssembly, onlyUnique = TRUE)
grLiftOver(gr, targetAssembly, onlyUnique = TRUE)
gr |
|
targetAssembly |
character string specifying the target assembly |
GRanges
object with coordinates that could uniquely be
Compute pairwise distances between the elements of two GRanges
objects,
taking orientation and position into account.
(wrapper for GRanges::distance
)
grSignedDistance(gr1, gr2)
grSignedDistance(gr1, gr2)
gr1 |
|
gr2 |
|
vector of pairwise distances
Elements in which the region in gr2 is upstream of the region in gr1 will be assigned negative distances.
"Upstream" is defined based on the orientation of the regions in gr1
.
Tile each element in a GRanges
object into equally-sized windows.
If the length of an element is not divisible by the window-size, each element will be adjusted to match a multiple of the desired window-size
grTile(gr, tile.width = 200, keepMetadata = TRUE)
grTile(gr, tile.width = 200, keepMetadata = TRUE)
gr |
|
tile.width |
length of the tiling window |
keepMetadata |
Should the metadata columns for each element be preserved in the resulting object |
GRanges
containing the tiling regions. Additional metadata columns named .orgIdx
, .winIdx
denote the indices
of the original element and the window respectively
Find the occurrences of items in a list of vectors
indicesInList(x, l)
indicesInList(x, l)
x |
vector of items to be found in the list |
l |
list of vectors in which |
a list containing an element for each item in x
that contains the indices of its occurrence in l
l <- list(1:3, 4:5, 5:9) x <- c(2,3,5,666,8,5) indicesInList(x, l)
l <- list(1:3, 4:5, 5:9) x <- c(2,3,5,666,8,5) indicesInList(x, l)
plot a single vector as kernel density estimation (kde.plot.simple), plot columns of a matrix as kernel density estimation (kde.plot.matrix)
kde.plot.simple(x, initial = FALSE, col = c("#00640044"), ...) kde.plot.matrix(X, col = makeTrans(rainbow(ncol(X))), legend = TRUE, ...)
kde.plot.simple(x, initial = FALSE, col = c("#00640044"), ...) kde.plot.matrix(X, col = makeTrans(rainbow(ncol(X))), legend = TRUE, ...)
x |
values |
initial |
is the plot initial, i.e. should the plot() function be called |
col |
color(s) |
... |
more graphical parameters |
X |
matrix |
legend |
add a color legend with colnames of the matrix |
Nothing particularly interesting
kde.plot.simple(c(1:10,rep(5,3)),initial=TRUE,col=c("#00640044"),main="Some plot") kde.plot.simple(rep(8,2),initial=FALSE,col=c("#64640044")) dd <- USJudgeRatings dd[,5] <- 1/dd[,5] tt <- dd[,1:5] kde.plot.matrix(tt)
kde.plot.simple(c(1:10,rep(5,3)),initial=TRUE,col=c("#00640044"),main="Some plot") kde.plot.simple(rep(8,2),initial=FALSE,col=c("#64640044")) dd <- USJudgeRatings dd[,5] <- 1/dd[,5] tt <- dd[,1:5] kde.plot.matrix(tt)
Load LOLA databases from disk and merge them
loadLolaDbs(lolaDbPaths, collections = NULL)
loadLolaDbs(lolaDbPaths, collections = NULL)
lolaDbPaths |
vector of names of LOLA DB paths to be loaded |
collections |
Restrict the database loading to this list of collections.
passed to |
LOLA DB list as returned by LOLA::loadRegionDB
Fabian Mueller
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]])
# download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") lolaDb <- loadLolaDbs(lolaDirs[["hg19"]])
Loads RnBeads analysis results (RnBSet object, differential methylation) and optionally runs the corresponding preanalysis script and sets options
loadRnBeadsAnalysis( input, type = "cluster_run", preprocessed = TRUE, setOptions = TRUE, preAnalysis = TRUE, diffMeth = TRUE )
loadRnBeadsAnalysis( input, type = "cluster_run", preprocessed = TRUE, setOptions = TRUE, preAnalysis = TRUE, diffMeth = TRUE )
input |
input directory |
type |
analysis type. Currently only "cluster_run" is supported |
preprocessed |
determines the type of RnBSet object to be loaded. If |
setOptions |
should the analysis options be set from the options settings of the RnBeads run? |
preAnalysis |
should the corresponding preanalysis script be called |
diffMeth |
should the differential analysis result be loaded in addition? |
A list
containing the RnBSet
object (list item rnbs
) and optionally
the differential methylaiton result (list item diffmeth
)
Fabian Mueller
plot a barplot of LOLA enrichment results
lolaBarPlot( lolaDb, lolaRes, scoreCol = "pValueLog", orderCol = scoreCol, signifCol = "qValue", includedCollections = c(), recalc = TRUE, pvalCut = 0.01, maxTerms = 50, colorpanel = sample(rainbow(maxTerms, v = 0.5)), groupByCollection = TRUE, orderDecreasing = NULL, appendTermDbId = TRUE )
lolaBarPlot( lolaDb, lolaRes, scoreCol = "pValueLog", orderCol = scoreCol, signifCol = "qValue", includedCollections = c(), recalc = TRUE, pvalCut = 0.01, maxTerms = 50, colorpanel = sample(rainbow(maxTerms, v = 0.5)), groupByCollection = TRUE, orderDecreasing = NULL, appendTermDbId = TRUE )
lolaDb |
LOLA DB object as returned by |
lolaRes |
LOLA enrichment result as returned by the |
scoreCol |
column name in |
orderCol |
column name in |
signifCol |
column name of the significance score in |
includedCollections |
vector of collection names to be included in the plot. If empty (default), all collections are used |
recalc |
recalculate adjusted p-value/q-value and ranks after the specified subsetting (by |
pvalCut |
p-value cutoff to be employed for filtering the results |
maxTerms |
maximum number of items to be included in the plot |
colorpanel |
colors to be used for coloring the bars according to "target" (see |
groupByCollection |
facet the plot by collection |
orderDecreasing |
flag indicating whether the value in |
appendTermDbId |
attach the index of the item in the LOLA DB object to the name of the set |
ggplot object containing the plot
Fabian Mueller
# example taken from RnBeads library(RnBeads.hg19) data(small.example.object) logger.start(fname=NA) # compute differential methylation dm <- rnb.execute.computeDiffMeth(rnb.set.example,pheno.cols=c("Sample_Group","Treatment")) # download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") # perform enrichment analysis res <- performLolaEnrichment.diffMeth(rnb.set.example,dm,lolaDirs[["hg19"]]) # select the 500 most hypermethylated tiling regions in ESCs compared to iPSCs # in the example dataset lolaRes <- res$region[["hESC vs. hiPSC (based on Sample_Group)"]][["tiling"]] lolaRes <- lolaRes[lolaRes$userSet=="rankCut_500_hyper",] # plot lolaBarPlot(res$lolaDb, lolaRes, scoreCol="oddsRatio", orderCol="maxRnk", pvalCut=0.05)
# example taken from RnBeads library(RnBeads.hg19) data(small.example.object) logger.start(fname=NA) # compute differential methylation dm <- rnb.execute.computeDiffMeth(rnb.set.example,pheno.cols=c("Sample_Group","Treatment")) # download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") # perform enrichment analysis res <- performLolaEnrichment.diffMeth(rnb.set.example,dm,lolaDirs[["hg19"]]) # select the 500 most hypermethylated tiling regions in ESCs compared to iPSCs # in the example dataset lolaRes <- res$region[["hESC vs. hiPSC (based on Sample_Group)"]][["tiling"]] lolaRes <- lolaRes[lolaRes$userSet=="rankCut_500_hyper",] # plot lolaBarPlot(res$lolaDb, lolaRes, scoreCol="oddsRatio", orderCol="maxRnk", pvalCut=0.05)
plot a boxplot showing LOLA enrichment results per "target" group (see getTargetFromLolaDb
for an explanation of
"target").
lolaBoxPlotPerTarget( lolaDb, lolaRes, scoreCol = "pValueLog", orderCol = scoreCol, signifCol = "qValue", includedCollections = c(), recalc = TRUE, pvalCut = 0.01, maxTerms = 50, colorpanel = c(), groupByCollection = TRUE, orderDecreasing = NULL, scoreDecreasing = NULL )
lolaBoxPlotPerTarget( lolaDb, lolaRes, scoreCol = "pValueLog", orderCol = scoreCol, signifCol = "qValue", includedCollections = c(), recalc = TRUE, pvalCut = 0.01, maxTerms = 50, colorpanel = c(), groupByCollection = TRUE, orderDecreasing = NULL, scoreDecreasing = NULL )
lolaDb |
LOLA DB object as returned by |
lolaRes |
LOLA enrichment result as returned by the |
scoreCol |
column name in |
orderCol |
column name in |
signifCol |
column name of the significance score in |
includedCollections |
vector of collection names to be included in the plot. If empty (default), all collections are used |
recalc |
recalculate adjusted p-value/q-value and ranks after the specified subsetting (by |
pvalCut |
p-value cutoff to be employed for filtering the results |
maxTerms |
maximum number of items to be included in the plot |
colorpanel |
colors to be used for coloring the bars according to "target" (see |
groupByCollection |
facet the plot by collection |
orderDecreasing |
flag indicating whether the value in |
scoreDecreasing |
flag indicating whether the value in |
ggplot object containing the plot
Fabian Mueller
# example taken from RnBeads library(RnBeads.hg19) data(small.example.object) logger.start(fname=NA) # compute differential methylation dm <- rnb.execute.computeDiffMeth(rnb.set.example,pheno.cols=c("Sample_Group","Treatment")) # download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") # perform enrichment analysis res <- performLolaEnrichment.diffMeth(rnb.set.example,dm,lolaDirs[["hg19"]]) # select the 500 most hypermethylated tiling regions in ESCs compared to iPSCs # in the example dataset lolaRes <- res$region[["hESC vs. hiPSC (based on Sample_Group)"]][["tiling"]] lolaRes <- lolaRes[lolaRes$userSet=="rankCut_500_hyper",] # plot lolaBoxPlotPerTarget(res$lolaDb, lolaRes, scoreCol="oddsRatio", orderCol="maxRnk", pvalCut=0.05)
# example taken from RnBeads library(RnBeads.hg19) data(small.example.object) logger.start(fname=NA) # compute differential methylation dm <- rnb.execute.computeDiffMeth(rnb.set.example,pheno.cols=c("Sample_Group","Treatment")) # download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") # perform enrichment analysis res <- performLolaEnrichment.diffMeth(rnb.set.example,dm,lolaDirs[["hg19"]]) # select the 500 most hypermethylated tiling regions in ESCs compared to iPSCs # in the example dataset lolaRes <- res$region[["hESC vs. hiPSC (based on Sample_Group)"]][["tiling"]] lolaRes <- lolaRes[lolaRes$userSet=="rankCut_500_hyper",] # plot lolaBoxPlotPerTarget(res$lolaDb, lolaRes, scoreCol="oddsRatio", orderCol="maxRnk", pvalCut=0.05)
lolaRegionSetHeatmap Plot a heatmap in which the rows are different user sets and the color corresponds to an enrichment score
lolaRegionSetHeatmap( lolaDb, lolaRes, scoreCol = "pValueLog", orderCol = scoreCol, signifCol = "qValue", markSignif = FALSE, includedCollections = c(), recalc = TRUE, pvalCut = 0.01, maxTerms = 50, userSetOrder = NULL, colorpanel = colpal.cont(9, "cb.OrRd"), colorpanelLimits = rep(as.numeric(NA), 2), groupByCollection = TRUE, orderDecreasing = NULL, appendTermDbId = TRUE )
lolaRegionSetHeatmap( lolaDb, lolaRes, scoreCol = "pValueLog", orderCol = scoreCol, signifCol = "qValue", markSignif = FALSE, includedCollections = c(), recalc = TRUE, pvalCut = 0.01, maxTerms = 50, userSetOrder = NULL, colorpanel = colpal.cont(9, "cb.OrRd"), colorpanelLimits = rep(as.numeric(NA), 2), groupByCollection = TRUE, orderDecreasing = NULL, appendTermDbId = TRUE )
lolaDb |
LOLA DB object as returned by |
lolaRes |
LOLA enrichment result as returned by the |
scoreCol |
column name in |
orderCol |
column name in |
signifCol |
column name of the significance score in |
markSignif |
mark significant enrichments in the heatmap |
includedCollections |
vector of collection names to be included in the plot. If empty (default), all collections are used |
recalc |
recalculate adjusted p-value/q-value and ranks after the specified subsetting (by |
pvalCut |
p-value cutoff (negative log10) to be employed for filtering the results |
maxTerms |
maximum number of items to be included in the plot |
userSetOrder |
the order in which the user sets are displayed.
|
colorpanel |
colorpanel for the heatmap gradient |
groupByCollection |
facet the plot by collection |
orderDecreasing |
flag indicating whether the value in |
appendTermDbId |
attach the index of the item in the LOLA DB object to the name of the set |
ggplot object containing the plot
Fabian Mueller
plot a volcano plot showing LOLA enrichment results: LOLA p-value against the log-odds score. Colored by rank
lolaVolcanoPlot( lolaDb, lolaRes, includedCollections = c(), signifCol = "qValue", recalc = TRUE, colorBy = "maxRnk", colorpanel = c() )
lolaVolcanoPlot( lolaDb, lolaRes, includedCollections = c(), signifCol = "qValue", recalc = TRUE, colorBy = "maxRnk", colorpanel = c() )
lolaDb |
LOLA DB object as returned by |
lolaRes |
LOLA enrichment result as returned by the |
includedCollections |
vector of collection names to be included in the plot. If empty (default), all collections are used |
signifCol |
column name of the significance score in |
recalc |
recalculate adjusted p-value/q-value and ranks after the specified subsetting (by |
colorBy |
annotation/column in the the LOLA DB that should be used for point coloring |
colorpanel |
colors to be used for coloring the points |
ggplot object containing the plot
Fabian Mueller
# example taken from RnBeads library(RnBeads.hg19) data(small.example.object) logger.start(fname=NA) # compute differential methylation dm <- rnb.execute.computeDiffMeth(rnb.set.example,pheno.cols=c("Sample_Group","Treatment")) # download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") # perform enrichment analysis res <- performLolaEnrichment.diffMeth(rnb.set.example,dm,lolaDirs[["hg19"]]) # select the 500 most hypermethylated tiling regions in ESCs compared to iPSCs # in the example dataset lolaRes <- res$region[["hESC vs. hiPSC (based on Sample_Group)"]][["tiling"]] lolaRes <- lolaRes[lolaRes$userSet=="rankCut_500_hyper",] # plot lolaVolcanoPlot(res$lolaDb, lolaRes, signifCol="qValue")
# example taken from RnBeads library(RnBeads.hg19) data(small.example.object) logger.start(fname=NA) # compute differential methylation dm <- rnb.execute.computeDiffMeth(rnb.set.example,pheno.cols=c("Sample_Group","Treatment")) # download LOLA DB lolaDest <- tempfile() dir.create(lolaDest) lolaDirs <- downloadLolaDbs(lolaDest, dbs="LOLACore") # perform enrichment analysis res <- performLolaEnrichment.diffMeth(rnb.set.example,dm,lolaDirs[["hg19"]]) # select the 500 most hypermethylated tiling regions in ESCs compared to iPSCs # in the example dataset lolaRes <- res$region[["hESC vs. hiPSC (based on Sample_Group)"]][["tiling"]] lolaRes <- lolaRes[lolaRes$userSet=="rankCut_500_hyper",] # plot lolaVolcanoPlot(res$lolaDb, lolaRes, signifCol="qValue")
make a vector of colors transparent
makeTrans(ccc, isText = FALSE, transparancy.val = "44")
makeTrans(ccc, isText = FALSE, transparancy.val = "44")
ccc |
color vector to make transparent |
isText |
are the colors textstrings (as opposed to hex value strings)? |
transparancy.val |
string value for transparancy |
a vector of colors with transparancy (hex strings)
makeTrans(rainbow(6)) makeTrans(c("red","dark blue","coral"),isText=TRUE)
makeTrans(rainbow(6)) makeTrans(c("red","dark blue","coral"),isText=TRUE)
match commonly used strand names to "+", "-", "*"
matchStrand(values)
matchStrand(values)
values |
character vector or factor of strand names |
Factor of genomic strand (with levels "+", "-", "*"
)
normalize a string by removing special characters and replacing whitespaces and dots and afterwards remove all leading and trailing whitespaces and special characters By default, underscore is the replacement character. Avoids consecutive underscores.
normalize.str(x, resolve.camel = FALSE, return.camel = FALSE)
normalize.str(x, resolve.camel = FALSE, return.camel = FALSE)
resolve.camel |
Is the string in camelCase and should this be resolved to snake_case? |
return.camel |
should camelCase be outputed rather than undescores? |
a |
string or string vector |
the normalized string(s)
normalize.str("_ (b)lA BLu[bb.blA\tblubb- bla)\n_")
normalize.str("_ (b)lA BLu[bb.blA\tblubb- bla)\n_")
Performs percentile normalization on the columns of a matrix, i.e. each element in a column will be the percentile it lies in in its column
normalizePercentile(X)
normalizePercentile(X)
X |
A matrix which should be normalized |
a matrix containing the normalized values
Fabian Mueller
Performs rank normalization on the columns of a matrix
normalizeRank(X, out = "rank", ties.method = "average")
normalizeRank(X, out = "rank", ties.method = "average")
X |
A matrix which should be normalized |
out |
output type. Either |
ties.method |
method for breaking ties (see |
a matrix containing the normalized values
Fabian Mueller
Pair plot with correlation values colored and resized on the upper right diagonal and density scatter plot on the lower left diagonal
pairsDensCor( tt, colscheme = c(gplots::colorpanel(100, "blue", "white"), gplots::colorpanel(100, "white", "red")), ... )
pairsDensCor( tt, colscheme = c(gplots::colorpanel(100, "blue", "white"), gplots::colorpanel(100, "white", "red")), ... )
tt |
table to be visualized |
colscheme |
colorscheme to be used for correlation |
... |
more plotting parameters |
Nothing particularly interesting
dd <- USJudgeRatings dd[,5] <- 1/dd[,5] tt <- dd[,1:5] pairsDensCor(tt)
dd <- USJudgeRatings dd[,5] <- 1/dd[,5] tt <- dd[,1:5] pairsDensCor(tt)
creates a correlation panel. The correlation values are colored and fontsize is proportional to amount of correlation
panel.cor.col(x, y, digits = 2, prefix = "", cex.cor, ...)
panel.cor.col(x, y, digits = 2, prefix = "", cex.cor, ...)
x |
x |
y |
y |
digits |
number of digits to be displayed |
prefix |
prefix for correlation text |
cex.cor |
cex for correlation text |
... |
more plotting parameters |
Nothing particularly interesting
creates a scatterplot density panel.
panel.density(x, y, ...)
panel.density(x, y, ...)
x |
x |
y |
y |
... |
more plotting parameters |
Nothing particularly interesting
parser for command line arguments
parse.cl.args()
parse.cl.args()
a named list with command line arguments
cmd.args <- parse.cl.args()
cmd.args <- parse.cl.args()
parser for the ENCODE projects controlled vocabulary file
parse.encode.cv.file( cvFile = "http://hgdownload.cse.ucsc.edu/goldenPath/encodeDCC/cv.ra" )
parse.encode.cv.file( cvFile = "http://hgdownload.cse.ucsc.edu/goldenPath/encodeDCC/cv.ra" )
cvFile |
the file location for the ENCODE controlled vocabulary file. Defaults to the one provided by ENCODE |
a list containing blank line seperated blocks in each element. Each element is a named list containing the content to each keyword. a keyword is the first word in a line.
cv.blocks <- parse.cv.file()
cv.blocks <- parse.cv.file()
Wrapper for quickly saving plot to temporary pdf file. terminate using dev.off()
pdftemp(fn = paste0("~/tmp_work/", getHashString("rplot"), ".pdf"), ...)
pdftemp(fn = paste0("~/tmp_work/", getHashString("rplot"), ".pdf"), ...)
fn |
file name |
... |
see |
nothing of particular interest
Generate a plots with multiple methods and parameter settings from a feature matrix
plotAllDimRed( X, fn.prefix = NULL, fn.suffix = "", annot = NULL, distMethods = c(euc = "euclidean", man = "manhattan"), width = 10, height = 10, ... )
plotAllDimRed( X, fn.prefix = NULL, fn.suffix = "", annot = NULL, distMethods = c(euc = "euclidean", man = "manhattan"), width = 10, height = 10, ... )
X |
feature matrix containing one row for each observation and one column for each feature |
fn.prefix |
file prefix to be used for the resulting plots.
If |
fn.suffix |
file suffix to be used for the resulting plots |
annot |
annotation matrix with the same number of rows as |
distMethods |
distance methods for MDS and t-SNE |
width |
width of the resulting plot |
height |
height of the resulting plot |
... |
arguments to be passed on to |
Currently, PCA, MDS and t-SNE are employed by default with euclidean and manhattan distance metrics where applicable
(invisibly) a list of lists containing the created plots as ggplot objects and additional info for each plot
Fabian Mueller
Get a continuous color palette
plotColpal(cp, type = "pie")
plotColpal(cp, type = "pie")
cp |
color palette, i.e. vector of colors |
type |
pie chart or stripes |
nothing of particular interest
Fabian Mueller
Plot a correlation matrix as heatmap. Wraps around pheatmap
. Note that no clustering will be performed if not supplied with an appropriate clustering dendrogram
plotCorPhm( cc, clustDend = NULL, sampleAnnot = NA, color = colorRampPalette(rev(colpal.cont(n = 11, name = "cb.RdBu")))(100), breaks = seq(-1 - 1e-06, 1 + 1e-06, length.out = length(color) + 1), border_color = NA, ... )
plotCorPhm( cc, clustDend = NULL, sampleAnnot = NA, color = colorRampPalette(rev(colpal.cont(n = 11, name = "cb.RdBu")))(100), breaks = seq(-1 - 1e-06, 1 + 1e-06, length.out = length(color) + 1), border_color = NA, ... )
cc |
a correlation matrix (as returned by |
clustDend |
a clustering dendrogram to be used. Set to |
sampleAnnot |
a data.frame containing sample information to color by (corrsponds to |
color |
see |
breaks |
see |
border_color |
see |
... |
parameters passed on to |
invisibly the result of a call to pheatmap()
Fabian Mueller
Generate a plot from a feature matrix
plotDimRed( X, dimRedFun = getDimRedCoords.pca, annot = NULL, colorCol = NULL, shapeCol = NULL, colScheme = NULL, ptSize = 3, addLabels = FALSE, addDensity = FALSE, annot.text = NULL, ... )
plotDimRed( X, dimRedFun = getDimRedCoords.pca, annot = NULL, colorCol = NULL, shapeCol = NULL, colScheme = NULL, ptSize = 3, addLabels = FALSE, addDensity = FALSE, annot.text = NULL, ... )
X |
feature matrix containing one row for each observation and one column for each feature |
dimRedFun |
function to do dimension reduction. E.g. |
annot |
annotation matrix with the same number of rows as |
colorCol |
name or index in the annotation matrix ( |
shapeCol |
name or index in the annotation matrix ( |
colScheme |
color sheme to be used in coloring the points |
ptSize |
size of the points in the scatterplot |
addLabels |
should observation labels be added to each point |
addDensity |
should Gaussian Kernel density estimation be performed and the contour lines plotted for each color group |
annot.text |
optional text to be added in the lower right corner of the plot |
... |
arguments to be passed on to |
a ggplot2
object containing the dimension reduction plot
Fabian Mueller
Conduct a Fisher's exact test and plot the results as a heatmap
plotFisherTest(x, y = NULL, name.x = NULL, name.y = NULL, ...)
plotFisherTest(x, y = NULL, name.x = NULL, name.y = NULL, ...)
x |
factor object or one that can be coerced to one. Alternative a 2x2 contingency matrix |
y |
factor object or one that can be coerced to one |
name.x |
optional character string specifying the name for the first grouping |
name.y |
optional character string specifying the name for the second grouping |
... |
arguments passed on to |
an S3
object containing the test result object as returned by fisher.test
and a ggplot
object
Fabian Mueller
Wrapper for quickly saving plot to temporary png file. terminate using dev.off()
pngtemp( fn = paste0("~/tmp_work/", getHashString("rplot"), ".png"), width = 1024, height = 1024, ... )
pngtemp( fn = paste0("~/tmp_work/", getHashString("rplot"), ".png"), width = 1024, height = 1024, ... )
fn |
file name |
... |
see |
nothing of particular interest
generate a random grouped heatmap using ComplexHeatmap
.
randomGroupedHeatmap( n.row = 20, n.col = 6, ngrps.row = 2, ngrps.col = 3, cols = NULL, ... )
randomGroupedHeatmap( n.row = 20, n.col = 6, ngrps.row = 2, ngrps.col = 3, cols = NULL, ... )
n.row |
number of rows |
n.col |
number of columns |
ngrps.row |
number of groups to group rows into |
ngrps.col |
number of groups to group columns into |
cols |
color scheme. Should be a color character vector.
If |
... |
parameters passed on to |
a ComplexHeatmap::Heatmap
object containing the heatmap
Fabian Mueller
randomGroupedHeatmap(n.row=10, n.col=3, ngrps.row=2, ngrps.col=3, cols=colpal.cont(n=9, name="viridis")) randomGroupedHeatmap(n.row=100, n.col=18, ngrps.row=3, ngrps.col=3, cols=colpal.cont(n=9, name="cb.BrBG")) pdftemp() draw(randomGroupedHeatmap(n.row=100, n.col=6, ngrps.row=3, ngrps.col=3, cols=colpal.PhFr.a)) dev.off()
randomGroupedHeatmap(n.row=10, n.col=3, ngrps.row=2, ngrps.col=3, cols=colpal.cont(n=9, name="viridis")) randomGroupedHeatmap(n.row=100, n.col=18, ngrps.row=3, ngrps.col=3, cols=colpal.cont(n=9, name="cb.BrBG")) pdftemp() draw(randomGroupedHeatmap(n.row=100, n.col=6, ngrps.row=3, ngrps.col=3, cols=colpal.PhFr.a)) dev.off()
Wrapper around read.table
to read tab-separated tables by default
readTab( fn, sep = "\t", header = TRUE, stringsAsFactors = FALSE, quote = "", comment.char = "", na.strings = "", ... )
readTab( fn, sep = "\t", header = TRUE, stringsAsFactors = FALSE, quote = "", comment.char = "", na.strings = "", ... )
fn |
filename to read |
sep |
see |
header |
see |
stringsAsFactors |
see |
quote |
see |
comment.char |
see |
... |
passed to |
the result of read.table
Fabian Mueller
reloads a package without quitting the R session. Useful for developing packages interactively
reloadPackage(package.name)
reloadPackage(package.name)
package.name |
name (string) of the package to be reloaded |
result of library(package.name)
library(GenomicRanges) reloadPackage("GenomicRanges")
library(GenomicRanges) reloadPackage("GenomicRanges")
performs a two-sided Welch's t-test (unequal variances, equal or unequal sample sizes) on each row of a matrix X with the indices inds.1 vs indices idx2 as group assignments.
rowTtest(X, idx1, idx2 = -idx1, na.rm = FALSE, alternative = "two.sided")
rowTtest(X, idx1, idx2 = -idx1, na.rm = FALSE, alternative = "two.sided")
X |
Matrix on which the test is performed for every row |
idx1 |
column indices of group 1 members |
idx2 |
column indices of group 2 members |
na.rm |
Should NAs be removed (logical) |
alternative |
Testing alternative. Must be one of "two.sided" (default),"less","greater" or "all". in case of "all" a data frome with corresping alternative variables is returned. Otherwise the result is a vector. |
vector (or data.frame if alternative=="all") of p-values resulting from the Welch's t-test
Requires matrixStats
package
Fabian Mueller
runLOLA_list More robust version of lola for lists of user sets (to avoid "Negative c entry in table" errors)
runLOLA_list(userSets, userUniverse, lolaDb, ...)
runLOLA_list(userSets, userUniverse, lolaDb, ...)
userSets |
NAMED list or GRangesList of user sets |
userUniverse |
GRanges object to be used as universe (as required by |
lolaDb |
LOLA DB object as returned by |
... |
other arguments to iterate over |
LOLA result as returned by LOLA::runLOLA
Fabian Mueller
density scatterplot with highlighting the points of a certain group in a different color
scatter.twogroups( x, y, is.g, cols.all = blues9[-(1:3)], cols.g = c("coral", "darkred"), ... )
scatter.twogroups( x, y, is.g, cols.all = blues9[-(1:3)], cols.g = c("coral", "darkred"), ... )
x |
x coordinates |
y |
y coordinates |
is.g |
logical vector indicating whether a point is in the highlighted group |
cols.all |
colorscheme for all points |
cols.g |
colorscheme for the points in the highlighted group |
... |
more plotting parameters |
Nothing particularly interesting
Set the genome properties for a GRanges or GAlignments object given the name of a genome assembly
setGenomeProps( gr, assembly, dropUnknownChrs = TRUE, adjChrNames = TRUE, silent = FALSE, ... )
setGenomeProps( gr, assembly, dropUnknownChrs = TRUE, adjChrNames = TRUE, silent = FALSE, ... )
gr |
GRanges object or GAlignments object to modify |
assembly |
assembly |
dropUnknownChrs |
discard entries with seqnames not supported by assembly |
adjChrNames |
should the prefix "chr" be added to main chromosomes if not already present and chrMT be renamed to chrM? |
silent |
Limit logging to most important messages |
... |
arguments passed on to |
GRanges object with genome properties set
sort a GRanges
object
sortGr(gr, alnum = FALSE)
sortGr(gr, alnum = FALSE)
gr |
|
alnum |
sort chromosomes alphanumerically instead of by number |
sorted GRanges
object
trim a character vector to have a desired length by taking the beginning of the string and the end of the string
strTrim( ss, len.out = 50, trim.str = "...", len.pref = ceiling((len.out - nchar(trim.str))/2), len.suf = len.out - len.pref - nchar(trim.str) )
strTrim( ss, len.out = 50, trim.str = "...", len.pref = ceiling((len.out - nchar(trim.str))/2), len.suf = len.out - len.pref - nchar(trim.str) )
ss |
character vector |
len.out |
target output length to trim to |
trim.str |
string to place in between prefix and suffix |
len.pref |
length of the prefix to be used from the original string |
len.suf |
length of the suffix to be used from the original string |
character vector in which each element has length<=len.out
Fabian Mueller
prints overlap statistics for two sets
summarizeSetOverlap( set1, set2, set1name = "set1", set2name = "set2", doVenn = TRUE )
summarizeSetOverlap( set1, set2, set1name = "set1", set2name = "set2", doVenn = TRUE )
set1 |
vector containing elements in set 1 |
set2 |
vector containing elements in set 2 |
set1name |
name for set 1 |
set2name |
name for set 2 |
doVenn |
plot a Venn diagram |
nothing of interest. If doVenn
, a venn diagram will be plotted to the current plotting device
Fabian Mueller
summarizeSetOverlap(1:50, 23:100, "1:50", "23:100")
summarizeSetOverlap(1:50, 23:100, "1:50", "23:100")
Tests for association between two vectors. Based on RnBeads:::test.traits
testAssoc(x, y, permMat = NULL)
testAssoc(x, y, permMat = NULL)
x |
Sample values for the first trait. This must be a vector of type |
y |
Sample values for the second trait. This must be a vector of type |
permMat |
Matrix of sample permutations (indices of x that will be used in permutation tests) in case none of the traits is a |
List of four elements:
Error, if any, that prevented this function from computing a p-value for trait association.
Type of test performed. This is one of "Fisher"
, "Wilcoxon"
,
"Kruskal-Wallis"
, "Correlation"
or NA
. The last value indicates that
the traits cannot be tested for association.
Value of the pearson correlation coefficient between x
and y
,
or NA
if any of them is factor
.
Calculated p-value, or NA
if the traits cannot be tested for association.
Shortcut wrapper around aggregate
to search case insensive in a vector of strings
textSearch(s, x, ...)
textSearch(s, x, ...)
s |
string or expression |
x |
string vector to search in |
string vector of matches
Fabian Mueller
A ggplot2 theme based on theme_bw but with no grid lines and axis only on top and bottom
theme_nogrid(base_size = 8, base_family = "Helvetica")
theme_nogrid(base_size = 8, base_family = "Helvetica")
base_size |
base size |
base_family |
base family |
the theme structure
theme_set(theme_nogrid()) dframe <- data.frame(x=runif(100),y=runif(100)) ggplot(dframe,aes(x=x,y=y)) + geom_point()
theme_set(theme_nogrid()) dframe <- data.frame(x=runif(100),y=runif(100)) ggplot(dframe,aes(x=x,y=y)) + geom_point()
Generate a report with plots of UMAP dimension reduction plots for parameter combinations
umapParamGridReport( X, outDir, metric = c("euclidean"), min_dist = c(0.01, 0.05, seq(0.1, 0.9, by = 0.1)), n_neighbors = c(5, 15, 25, 50), ... )
umapParamGridReport( X, outDir, metric = c("euclidean"), min_dist = c(0.01, 0.05, seq(0.1, 0.9, by = 0.1)), n_neighbors = c(5, 15, 25, 50), ... )
X |
feature matrix containing one row for each observation and one column for each feature |
outDir |
output directory |
metric |
parameters passed on to |
min_dist |
parameters passed on to |
n_neighbors |
parameters passed on to |
... |
parameters passed on to |
a muReportR
report (HTML) showing dimension reduction plots for the grid search
Fabian Mueller
converts underscores to camel case in a (vector of) string(s)
underscore2camel(x)
underscore2camel(x)
a |
string or string vector |
the converted string(s)
underscore2camel("bla_blubb")
underscore2camel("bla_blubb")
unloads a package without quitting the R session. Useful for developing packages interactively
unloadPackage(package.name)
unloadPackage(package.name)
package.name |
name (string) of the package to be reloaded |
result of library(package.name)
library(GenomicRanges) unloadPackage("GenomicRanges")
library(GenomicRanges) unloadPackage("GenomicRanges")
Wrapper around write.table
to write tab-separated tables by default
writeTab( x, fn, sep = "\t", row.names = FALSE, col.names = TRUE, quote = FALSE, ... )
writeTab( x, fn, sep = "\t", row.names = FALSE, col.names = TRUE, quote = FALSE, ... )
x |
table to write to file |
fn |
filename to write to |
sep |
see |
row.names |
see |
col.names |
see |
quote |
see |
... |
passed to |
stringsAsFactors |
see |
the result of write.table
Fabian Mueller