Title: | Interactive and explorative visualization of SummarizedExperssionSet or ExpressionSet using omicsViewer |
---|---|
Description: | omicsViewer visualizes ExpressionSet (or SummarizedExperiment) in an interactive way. The omicsViewer has a separate back- and front-end. In the back-end, users need to prepare an ExpressionSet that contains all the necessary information for the downstream data interpretation. Some extra requirements on the headers of phenotype data or feature data are imposed so that the provided information can be clearly recognized by the front-end, at the same time, keep a minimum modification on the existing ExpressionSet object. The pure dependency on R/Bioconductor guarantees maximum flexibility in the statistical analysis in the back-end. Once the ExpressionSet is prepared, it can be visualized using the front-end, implemented by shiny and plotly. Both features and samples could be selected from (data) tables or graphs (scatter plot/heatmap). Different types of analyses, such as enrichment analysis (using Bioconductor package fgsea or fisher's exact test) and STRING network analysis, will be performed on the fly and the results are visualized simultaneously. When a subset of samples and a phenotype variable is selected, a significance test on means (t-test or ranked based test; when phenotype variable is quantitative) or test of independence (chi-square or fisher’s exact test; when phenotype data is categorical) will be performed to test the association between the phenotype of interest with the selected samples. Additionally, other analyses can be easily added as extra shiny modules. Therefore, omicsViewer will greatly facilitate data exploration, many different hypotheses can be explored in a short time without the need for knowledge of R. In addition, the resulting data could be easily shared using a shiny server. Otherwise, a standalone version of omicsViewer together with designated omics data could be easily created by integrating it with portable R, which can be shared with collaborators or submitted as supplementary data together with a manuscript. |
Authors: | Chen Meng [aut, cre] |
Maintainer: | Chen Meng <[email protected]> |
License: | GPL-2 |
Version: | 1.11.0 |
Built: | 2024-10-30 09:09:18 UTC |
Source: | https://github.com/bioc/omicsViewer |
convert e (inflection point) to EC50
.e2EC50(b, d, e, f)
.e2EC50(b, d, e, f)
b |
Hill's slope. The Hill's slope refers to the steepness of the curve. It could either be positive or negative. |
d |
Hihgest response value. |
e |
Inflection point. The inflection point is defined as the point on the curve where the curvature changes direction or signs. In models where f = 1 (2-4 parameter models), e is EC50. |
f |
Asymmetry factor. When f=1 we have a symmetrical curve around inflection point and so we have a four-parameters logistic equation. |
Only has an effect when using LL.5 and LL2.5 model
model fitted by drc
.modelFormula(x, b, c = 0, d = 1, e, f = 1)
.modelFormula(x, b, c = 0, d = 1, e, f = 1)
x |
numerical vector of doses/time points/concentrations |
b |
Hill's slope. The Hill's slope refers to the steepness of the curve. It could either be positive or negative. |
c |
Lowest response value. |
d |
Hihgest response value. |
e |
Inflection point. The inflection point is defined as the point on the curve where the curvature changes direction or signs. In models where f = 1 (2-4 parameter models), e is EC50. |
f |
Asymmetry factor. When f=1 we have a symmetrical curve around inflection point and so we have a four-parameters logistic equation. |
func(x) = c + (d - c) / (1 + (x/e)^b)^f
Function should only be used for the developers
app_module( input, output, session, .dir, filePattern = ".(RDS|db|sqlite|sqlite3)$", additionalTabs = NULL, ESVObj = reactive(NULL), esetLoader = readESVObj, exprsGetter = getExprs, pDataGetter = getPData, fDataGetter = getFData, imputeGetter = getExprsImpute, defaultAxisGetter = getAx, appName = "omicsViewer", appVersion = packageVersion("omicsViewer") )
app_module( input, output, session, .dir, filePattern = ".(RDS|db|sqlite|sqlite3)$", additionalTabs = NULL, ESVObj = reactive(NULL), esetLoader = readESVObj, exprsGetter = getExprs, pDataGetter = getPData, fDataGetter = getFData, imputeGetter = getExprsImpute, defaultAxisGetter = getAx, appName = "omicsViewer", appVersion = packageVersion("omicsViewer") )
input |
input |
output |
output |
session |
session |
.dir |
reactive; directory containing the .RDS file of |
filePattern |
file pattern to be displayed. |
additionalTabs |
additional tabs added to "Analyst" panel |
ESVObj |
the ESV object given, the drop down list should be disable in the "ui" component. |
esetLoader |
function to load the eset object, if an RDS file, should be "readRDS" |
exprsGetter |
function to get the expression matrix from eset |
pDataGetter |
function to get the phenotype data from eset |
fDataGetter |
function to get the feature data from eset |
imputeGetter |
function to get the imputed expression matrix from eset, only used when exporting imputed data to excel |
defaultAxisGetter |
function to get the default axes to be visualized. It should be a function with two arguments: x - the object loaded to the viewer; what - one of "sx", "sy", "fx" and "fy", representing the sample space x-axis, sample space y-axis, feature space x-axis and feature space y-axis respectively. |
appName |
name of the application |
appVersion |
version of the application |
do not return any values
if (interactive()) { dir <- system.file("extdata", package = "omicsViewer") server <- function(input, output, session) { callModule(app_module, id = "app", dir = reactive(dir)) } ui <- fluidPage( app_ui("app") ) shinyApp(ui = ui, server = server) }
if (interactive()) { dir <- system.file("extdata", package = "omicsViewer") server <- function(input, output, session) { callModule(app_module, id = "app", dir = reactive(dir)) } ui <- fluidPage( app_ui("app") ) shinyApp(ui = ui, server = server) }
Function should only be used for the developers
app_ui(id, showDropList = TRUE, activeTab = "Feature")
app_ui(id, showDropList = TRUE, activeTab = "Feature")
id |
id |
showDropList |
logical; whether to show the dropdown list to select RDS file, if the ESVObj is given, this should be set to "FALSE" |
activeTab |
one of "Feature", "Feature table", "Sample", "Sample table", "Heatmap" |
a list of UI components
if (interactive()) { dir <- system.file("extdata", package = "omicsViewer") server <- function(input, output, session) { callModule(app_module, id = "app", dir = reactive(dir)) } ui <- fluidPage( app_ui("app") ) shinyApp(ui = ui, server = server) }
if (interactive()) { dir <- system.file("extdata", package = "omicsViewer") server <- function(input, output, session) { callModule(app_module, id = "app", dir = reactive(dir)) } ui <- fluidPage( app_ui("app") ) shinyApp(ui = ui, server = server) }
Convert SummarizedExperiment to ExpressionSet retaining all attributes
asEsetWithAttr(x)
asEsetWithAttr(x)
x |
an object of class SummarizedExperiment |
an object of class ExpressionSet
This is a convenience function to perform correlation analysis,
the output is in a format ready to be incorporated into object to be
visualized by omicsViewer
.
correlationAnalysis(x, pheno, min.value = 12, prefix = "Cor")
correlationAnalysis(x, pheno, min.value = 12, prefix = "Cor")
x |
an expression matrix, rows are the features (e.g. proteins), columns are the samples |
pheno |
a |
min.value |
the minimum number of samples required in the correlation analysis, if lower than this number, NA will be returned. |
prefix |
prefix of the names. Usually don't need to be changed by the user.
When changes are needed, the prefix should be in a format like
[analysis name]|[subset] so the "analysis name" and "subset" can be selected
in the |
Every correlation analysis returns a data.frame
with five
columns:
R
- pearson correlation coefficient
N
- number of values used in the analysis
P
- p-values returned by pearson correlation analysis
logP
- log transformed p-values
range
- the range of values in expression matrix used in the analysis
e1 <- matrix(rnorm(500), 50, 10) rownames(e1) <- paste0("FT", 1:50) p1 <- matrix(rnorm(50), 10, 5) colnames(p1) <- paste0("PH", 1:5) colnames(e1) <- rownames(p1) <- paste0("S", 1:10) correlationAnalysis(x = e1, pheno = p1, min.value = 8)
e1 <- matrix(rnorm(500), 50, 10) rownames(e1) <- paste0("FT", 1:50) p1 <- matrix(rnorm(50), 10, 5) colnames(p1) <- paste0("PH", 1:5) colnames(e1) <- rownames(p1) <- paste0("S", 1:10) correlationAnalysis(x = e1, pheno = p1, min.value = 8)
convert a column compressed sparse matrix to a list
csc2list(x)
csc2list(x)
x |
a matrix or CsparseMatrix object |
a sparse frame in data.frame
Drawing ROC and PR curve
draw_roc_pr(value, label)
draw_roc_pr(value, label)
value |
a numerical vector indicates the predictions |
label |
true class labels, could be two or more unique values |
v <- sort(rnorm(100)) l <- sample(1:2, size = 100, replace = TRUE) draw_roc_pr(v, l) l <- rep(c("b", "c", "a", "d"), each = 25) draw_roc_pr(v, l) draw_roc_pr(v, sample(l))
v <- sort(rnorm(100)) l <- sample(1:2, size = 100, replace = TRUE) draw_roc_pr(v, l) l <- rep(c("b", "c", "a", "d"), each = 25) draw_roc_pr(v, l) draw_roc_pr(v, sample(l))
A convenient function to fit dose response models for every row in
an omics matrix using drm
function in the drc
package.
drmMat( x, fitvar, fitvar.name = c("Dose", "Time", "Concentration")[1], curveid = NA, fct.name = c("LL.4()", "LL.3()", "LL.2()", "LL.5()")[1] )
drmMat( x, fitvar, fitvar.name = c("Dose", "Time", "Concentration")[1], curveid = NA, fct.name = c("LL.4()", "LL.3()", "LL.2()", "LL.5()")[1] )
x |
a numerical matrix where the rows are features and columns are samples. |
fitvar |
a numerical variable has the same length as |
fitvar.name |
the name of the |
curveid |
a numeric vector or factor containing the grouping of the columns in x. |
fct.name |
the function name, e.g. "LL.4()", "LL.3()", "LL.2()" and "LL.5()",
which are defined in the |
a list of drc
object
omicsViewer
This is a convenience function to perform PCA on expression matrix,
the output of PCA
will be in a format ready to be incorporated into object to be visualized by
omicsViewer
.
exprspca(x, n = min(8, ncol(x) - 1), prefix = "PCA|All", fillNA = FALSE, ...)
exprspca(x, n = min(8, ncol(x) - 1), prefix = "PCA|All", fillNA = FALSE, ...)
x |
an expression matrix, where rows are features and samples are on columns. |
n |
number of components to keep |
prefix |
prefix of the names. Usually don't need to be changed by the user.
When changes are needed, the prefix should be in a format like
[analysis name]|[subset] so the "analysis name" and "subset" can be selected
in the |
fillNA |
logical; whether NA should be filled? If FALSE (default),
|
... |
other parameters passed to |
a data.frame
storing the PCA results
# reading expression packdir <- system.file("extdata", package = "omicsViewer") expr <- read.delim(file.path(packdir, "expressionMatrix.tsv"), stringsAsFactors = FALSE) # call PCA pc <- exprspca(expr) head(pc$samples) head(pc$features)
# reading expression packdir <- system.file("extdata", package = "omicsViewer") expr <- read.delim(file.path(packdir, "expressionMatrix.tsv"), stringsAsFactors = FALSE) # call PCA pc <- exprspca(expr) head(pc$samples) head(pc$features)
Add extra columns to the phenoData/colData or featureData/rowData in ExpressionSet/SummarizedExperiment
Add extra columns to the phenoData/colData or featureData/rowData in ExpressionSet/SummarizedExperiment
Add extra columns to the phenoData/colData or featureData/rowData in ExpressionSet/SummarizedExperiment
extendMetaData(object, newData, where) ## S4 method for signature 'ExpressionSet,data.frame' extendMetaData( object, newData, where = c("pData", "fData", "colData", "rowData")[1] ) ## S4 method for signature 'SummarizedExperiment,data.frame' extendMetaData( object, newData, where = c("pData", "fData", "colData", "rowData")[1] ) ## S4 method for signature 'SummarizedExperiment,DFrame' extendMetaData( object, newData, where = c("pData", "fData", "colData", "rowData")[1] )
extendMetaData(object, newData, where) ## S4 method for signature 'ExpressionSet,data.frame' extendMetaData( object, newData, where = c("pData", "fData", "colData", "rowData")[1] ) ## S4 method for signature 'SummarizedExperiment,data.frame' extendMetaData( object, newData, where = c("pData", "fData", "colData", "rowData")[1] ) ## S4 method for signature 'SummarizedExperiment,DFrame' extendMetaData( object, newData, where = c("pData", "fData", "colData", "rowData")[1] )
object |
an object of |
newData |
a |
where |
where to add the extra columns, should be one of "pData", "fData", "rowData" and "colData". |
an object of ExpressionSet-class
The attributes in the pheno data and feature data will be preserved
est <- Biobase::ExpressionSet(assayData=matrix(runif(1000), nrow=100, ncol=10)) Biobase::pData(est) est <- extendMetaData(est, data.frame(letter = letters[1:10]), where = "pData") Biobase::pData(est)
est <- Biobase::ExpressionSet(assayData=matrix(runif(1000), nrow=100, ncol=10)) Biobase::pData(est) est <- extendMetaData(est, data.frame(letter = letters[1:10]), where = "pData") Biobase::pData(est)
Extracting parameters from drc models
extractParamDC(mod, prefix = "ResponseCurve")
extractParamDC(mod, prefix = "ResponseCurve")
mod |
a drc object |
prefix |
for column header, the column will be named as prefix|curveid|curveparameter |
when LL2.X is used, e is estimated as log(e), this function will return e in linear scale instead.
Extracting parameter from a list of drc object and return a data.frame, which can be incorporated into the object visualized by omicsViewer
extractParamDCList(x, prefix = "ResponseCurve")
extractParamDCList(x, prefix = "ResponseCurve")
x |
a list of drc object |
prefix |
for column header |
a data.frame
Wrapper of fgseaMultilevel function to take binary gene set matrix as input
fgsea1(gs, stats, gs_desc = NULL, ...)
fgsea1(gs, stats, gs_desc = NULL, ...)
gs |
either a data.frame or a (sparse) matrix input. If a data.frame object is given, it should have at least three columns named as "featureId", "gsId" and "weight". If a matrix is given, the matrix is binary matrix where rows are features and columns are gene sets. The values in the matrix should be either 1 or 0 representing the presence and absence of a feature in the genesets, repectively. |
stats |
ranking stats |
gs_desc |
description of gene sets, it should be a named vector and the names should be the same as colnames(gs) |
... |
other parameters passed to fgseaMultilevel |
a data.frame
of fgsea results
## not for users # library(fgsea) # library(Biobase) # dat <- readRDS(system.file(package = "omicsViewer", "extdata/demo.RDS")) # fd <- fData(dat) # fdgs <- fd[, grep("^GS\|", colnames(fd))] # res <- fgsea1(fdgs, stats = fd$`t-test|OV_BR|md`, minSize = 5, maxSize = 500) # res <- fgsea1( # fdgs, stats = fd$`t-test|OV_BR|md`, # minSize = 5, maxSize = 500, gs_desc = colnames(fdgs))
## not for users # library(fgsea) # library(Biobase) # dat <- readRDS(system.file(package = "omicsViewer", "extdata/demo.RDS")) # fd <- fData(dat) # fdgs <- fd[, grep("^GS\|", colnames(fd))] # res <- fgsea1(fdgs, stats = fd$`t-test|OV_BR|md`, minSize = 5, maxSize = 500) # res <- fgsea1( # fdgs, stats = fd$`t-test|OV_BR|md`, # minSize = 5, maxSize = 500, gs_desc = colnames(fdgs))
This function is usually use to impute missing values in expression matrix, where the rows are feature and columns are samples. This function impute the missing values on the row-wise, that is, every row will be imputed using different constant.
fillNA( x, maxfill = quantile(x, probs = 0.15, na.rm = TRUE), fillingFun = function(x) min(x, na.rm = TRUE) - log10(2) )
fillNA( x, maxfill = quantile(x, probs = 0.15, na.rm = TRUE), fillingFun = function(x) min(x, na.rm = TRUE) - log10(2) )
x |
a matrix with NA values |
maxfill |
the maximum filled value, if the value calculated by |
fillingFun |
function to calculate the filling values. It should be a function accept at least one
argument "x", which is a row of input expression matrix. The default is
|
a matrix without NAs
The returned matrix may have -Inf, which may need to be filtered/replaced additionally
m <- matrix(rnorm(200), 20, 10) m[sample(1:200, size = 20)] <- NA mf <- fillNA(m)
m <- matrix(rnorm(200), 20, 10) m[sample(1:200, size = 20)] <- NA mf <- fillNA(m)
The function is used to filter rows with values of low intensities or do not reproducible presented in replicates.
filterRow(x, max.quantile = NULL, max.value = NULL, var = NULL, min.rep = 2)
filterRow(x, max.quantile = NULL, max.value = NULL, var = NULL, min.rep = 2)
x |
an expression matrix |
max.quantile |
a single numerical value between (0, 1), if the row maximum is smaller than this quantile (calculated from the whole matrix), the row will be removed. |
max.value |
a single numerical value, if the the maximum value of a rwo is
smaller than this value, the row will be removed. Only used if |
var |
variables has the same length as the column number in |
min.rep |
the minimum number of replicate in at least one of the groups, if less than this value, the row will be removed. |
a logical vector where the TRUE means row to keep
e1 <- matrix(rnorm(5000, sd = 0.3), 500, 10) + rnorm(500) f <- filterRow(x = e1, max.quantile = 0.25) table(f)
e1 <- matrix(rnorm(5000, sd = 0.3), 500, 10) + rnorm(500) f <- filterRow(x = e1, max.quantile = 0.25) table(f)
Get genes associated with search terms and AutoRIF annotations
getAutoRIF(term, rif = c("generif", "autorif")[1], filter = TRUE)
getAutoRIF(term, rif = c("generif", "autorif")[1], filter = TRUE)
term |
a character vector of terms want to search |
rif |
either autorif or generif, see "https://maayanlab.cloud/geneshot/" |
filter |
whether the result should be filtered. The least frequently mentioned genes (most like 1 or 2 times) will be removed. |
a data.frame
of 4 columns: gene, n, perc, rank.
https://amp.pharm.mssm.edu/geneshot/
Alexander Lachmann, Brian M Schilder, Megan L Wojciechowicz, Denis Torre, Maxim V Kuleshov, Alexandra B Keenan, Avi Ma’ayan, Geneshot: search engine for ranking genes from arbitrary text queries, Nucleic Acids Research, Volume 47, Issue W1, 02 July 2019, Pages W571–W577, https://doi.org/10.1093/nar/gkz393
Alexander Lachmann, Brian M Schilder, Megan L Wojciechowicz, Denis Torre, Maxim V Kuleshov, Alexandra B Keenan, Avi Ma’ayan, Geneshot: search engine for ranking genes from arbitrary text queries, Nucleic Acids Research, Volume 47, Issue W1, 02 July 2019, Pages W571–W577, https://doi.org/10.1093/nar/gkz393
a <- getAutoRIF("mtor signaling")
a <- getAutoRIF("mtor signaling")
Getting the experimental informatione (TMT or label free) from mqpar.xml file.
getMQParams(x)
getMQParams(x)
x |
the path to mqpar.xml file |
a list of MQ paramters
get uniprot reference proteome IDs
get uniprot reference proteome IDs
getUPRefProteomeID( domain = c("Eukaryota", "Archaea", "Bacteria", "Viruses")[1] ) downloadUPRefProteome( id, domain = c("Eukaryota", "Archaea", "Bacteria", "Viruses")[1], destdir = "./" )
getUPRefProteomeID( domain = c("Eukaryota", "Archaea", "Bacteria", "Viruses")[1] ) downloadUPRefProteome( id, domain = c("Eukaryota", "Archaea", "Bacteria", "Viruses")[1], destdir = "./" )
domain |
the domain, one of "Eukaryota", "Archaea", "Bacteria" or "Viruses" |
id |
the UP id to download |
destdir |
destination directory |
a character vector of UP ids
a character vector of UP ids
getUPRefProteomeID()
: get uniprot reference protein IDs
Annotation of gene/protein function using multiple IDs.
gsAnnotIdList( idList, gsIdMap, minSize = 5, maxSize = 500, data.frame = FALSE, sparse = TRUE )
gsAnnotIdList( idList, gsIdMap, minSize = 5, maxSize = 500, data.frame = FALSE, sparse = TRUE )
idList |
list of protein IDs, e.g. list(c("ID1", "ID2"), c("ID13"), c("ID4", "ID8", "ID10")) |
gsIdMap |
a data frame for geneset to id map, it has two columns - id: the ID column - term: annotation terms e.g. gsIdMap <- data.frame( id = c("ID1", "ID2", "ID1", "ID2", "ID8", "ID10"), term = c("T1", "T1", "T2", "T2", "T2", "T2"), stringsAsFactors = FALSE ) |
minSize |
minimum size of gene sets |
maxSize |
maximum size of gene sets |
data.frame |
logical; whether to organize the result into |
sparse |
logical; whether to return a sparse matrix, only used when data.frame=FALSE |
A binary matrix (if data.frame
= FALSE),
the number of rows is the same with length of idList, the columns
are the annotated gene set; or a data.frame
(if data.frame
=
TRUE) with three columns: featureId, gsId, weight.
terms <- data.frame( id = c("ID1", "ID2", "ID1", "ID2", "ID8", "ID10"), term = c("T1", "T1", "T2", "T2", "T2", "T2"), stringsAsFactors = FALSE ) features <- list(c("ID1", "ID2"), c("ID13"), c("ID4", "ID8", "ID10")) gsAnnotIdList(idList = features, gsIdMap = terms, minSize = 1, maxSize = 500) terms <- data.frame( id = c("ID1", "ID2", "ID1", "ID2", "ID8", "ID10", "ID4", "ID4"), term = c("T1", "T1", "T2", "T2", "T2", "T2", "T1", "T2"), stringsAsFactors = FALSE ) features <- list(F1 = c("ID1", "ID2", "ID4"), F2 = c("ID13"), F3 = c("ID4", "ID8", "ID10")) gsAnnotIdList(features, gsIdMap = terms, data.frame = TRUE, minSize = 1) gsAnnotIdList(features, gsIdMap = terms, data.frame = FALSE, minSize = 1)
terms <- data.frame( id = c("ID1", "ID2", "ID1", "ID2", "ID8", "ID10"), term = c("T1", "T1", "T2", "T2", "T2", "T2"), stringsAsFactors = FALSE ) features <- list(c("ID1", "ID2"), c("ID13"), c("ID4", "ID8", "ID10")) gsAnnotIdList(idList = features, gsIdMap = terms, minSize = 1, maxSize = 500) terms <- data.frame( id = c("ID1", "ID2", "ID1", "ID2", "ID8", "ID10", "ID4", "ID4"), term = c("T1", "T1", "T2", "T2", "T2", "T2", "T1", "T2"), stringsAsFactors = FALSE ) features <- list(F1 = c("ID1", "ID2", "ID4"), F2 = c("ID13"), F3 = c("ID4", "ID8", "ID10")) gsAnnotIdList(features, gsIdMap = terms, data.frame = TRUE, minSize = 1) gsAnnotIdList(features, gsIdMap = terms, data.frame = FALSE, minSize = 1)
Check whether an object has an attribute
hasAttr(x, attr.name)
hasAttr(x, attr.name)
x |
the object |
attr.name |
a character vector containing the name of attributes to be checked |
a logical value/vector has the same length as attr.name
Convert hclust object to/from single character
hclust2str(x) str2hclust(x)
hclust2str(x) str2hclust(x)
x |
a character of length one or an hclust object |
a character stores the hclust object
a hclust object
The $call element in hclust will not retained in the conversion. The conversion decrease the precision in $height element.
# not for end users # m <- matrix(rnorm(50), 25) # hc <- hclust(dist(m)) # plot(hc) # te <- hclust2str(hc) # hc2 <- str2hclust(te) # plot(hc2)
# not for end users # m <- matrix(rnorm(50), 25) # hc <- hclust(dist(m)) # plot(hc) # te <- hclust2str(hc) # hc2 <- str2hclust(te) # plot(hc2)
Calculate Jaccard distance from a list
jaccardList(x)
jaccardList(x)
x |
a list |
an dist object
convert a list to column compressed sparse matrix
list2csc(l, dimnames)
list2csc(l, dimnames)
l |
a data.frame with at least two columns - featureId, gsId; optionally a "weight" column. |
dimnames |
a list of dimnames, should contain at least one element for the row names. |
a sparse matrix, CsparseMatrix, column compressed
This is a convenience function to perform multiple student's t-test.
The output is in a format ready to be incorporated into object to be visualized by
omicsViewer
. This function use t.test
.
multi.t.test(x, pheno, compare = NULL, fillNA = FALSE, ...)
multi.t.test(x, pheno, compare = NULL, fillNA = FALSE, ...)
x |
an expression matrix, usually log10 transformed. |
pheno |
phenotype data of x, the number of rows in |
compare |
NULL or a matrix with three columns to define the comparisons to do.
When a matrix is given, the first column should be one of the column headers
in |
fillNA |
logical; whether NA should be filled? If FALSE (default), t test
will be performed whenever possible. If not possible, then NA will be returned.
If TRUE, the missing value will be replaced using |
... |
other parameters passed to |
a data.frame
stores the t-test results with the follow columns:
mean|[selected header in pheno]|[group 1 in test]
- The mean value of group 1
n value|[selected header in pheno]|[group 1 in test]
- The number of value used in the test for group 1
quantile|[selected header in pheno]|[group 1 in test]
- The quantile of means values in group 1
mean|[selected header in pheno]|[group 2 in test]
- The mean value of group 2
n value|[selected header in pheno]|[group 2 in test]
- The number of value used in the test for group 2
quantile|[selected header in pheno]|[group 2 in test]
- The quantile of means values in group 2
ttest|[group 1 in test]_vs_[group 2 in test]|pvalue
- The p-value return by t.test
ttest|[group 1 in test]_vs_[group 2 in test]|log.pvalue
- The -log10 transformed p-value
ttest|[group 1 in test]_vs_[group 2 in test]|fdr
- The BH method corrected p-values, e.g. FDR
ttest|[group 1 in test]_vs_[group 2 in test]|log.fdr
- The -log10 transformed FDR
ttest|[group 1 in test]_vs_[group 2 in test]|mean.diff
- The difference between the means of the two groups, e.g. fold change
# reading expression packdir <- system.file("extdata", package = "omicsViewer") expr <- read.delim(file.path(packdir, "expressionMatrix.tsv"), stringsAsFactors = FALSE) # reading phenotype data pd <- read.delim(file.path(packdir, "sampleGeneral.tsv"), stringsAsFactors = FALSE) ## Single t-test head(pd) # define comparisons tests <- c("Origin", "RE", "ME") tres <- multi.t.test(x = expr, pheno = pd, compare = tests) ## multiple t-test head(pd) # define comparisons tests <- rbind( c("Origin", "RE", "ME"), c("Origin", "RE", "LE"), c('TP53.Status', "MT", "WT") ) tres <- multi.t.test(x = expr, pheno = pd, compare = tests)
# reading expression packdir <- system.file("extdata", package = "omicsViewer") expr <- read.delim(file.path(packdir, "expressionMatrix.tsv"), stringsAsFactors = FALSE) # reading phenotype data pd <- read.delim(file.path(packdir, "sampleGeneral.tsv"), stringsAsFactors = FALSE) ## Single t-test head(pd) # define comparisons tests <- c("Origin", "RE", "ME") tres <- multi.t.test(x = expr, pheno = pd, compare = tests) ## multiple t-test head(pd) # define comparisons tests <- rbind( c("Origin", "RE", "ME"), c("Origin", "RE", "LE"), c('TP53.Status', "MT", "WT") ) tres <- multi.t.test(x = expr, pheno = pd, compare = tests)
Mainly used in the shiny app to generate reproducible k distinct colors.
nColors(k, stop = FALSE)
nColors(k, stop = FALSE)
k |
a number between 1 to 60 tells how many distinct colors to use |
stop |
logical; whether the function should return an error message if k is not in the range of 2 to 60. Default FALSE, the function will return NULL. |
a vector of hex code for k colors or NULL
nColors(5) nColors(1, stop = FALSE)
nColors(5) nColors(1, stop = FALSE)
Normalization using n quantiles
normalize.nQuantiles(x, probs = 0.5, shareFeature = FALSE, ref = 1)
normalize.nQuantiles(x, probs = 0.5, shareFeature = FALSE, ref = 1)
x |
an expression matrix, usually log transformed |
probs |
the quantiles to be aligned across samples. If |
shareFeature |
logocal; if TRUE, the normalization will be based on the shared features between samples |
ref |
the columns name or index to specify the reference sample, only used
when |
a normalized matrix
e1 <- matrix(rnorm(5000), 500, 10) e1[, 6:10] <- 0.3 *e1[, 6:10] + 3 boxplot(e1) # median centering, no variance correction e2 <- normalize.nQuantiles(x = e1, probs = 0.5) boxplot(e2) # median centering + variance stablization e3 <- normalize.nQuantiles(x = e1, probs = seq(0.25, 0.75, by = 0.1)) boxplot(e3)
e1 <- matrix(rnorm(5000), 500, 10) e1[, 6:10] <- 0.3 *e1[, 6:10] + 3 boxplot(e1) # median centering, no variance correction e2 <- normalize.nQuantiles(x = e1, probs = 0.5) boxplot(e2) # median centering + variance stablization e3 <- normalize.nQuantiles(x = e1, probs = seq(0.25, 0.75, by = 0.1)) boxplot(e3)
Normalize total sum
normalize.totsum(x)
normalize.totsum(x)
x |
a log10 transformed expression matrix |
a normalized matrix
e1 <- matrix(rnorm(5000), 500, 10) e1[, 6:10] <- e1[, 6:10]+3 boxplot(e1) e2 <- normalize.totsum(x = e1) boxplot(e2)
e1 <- matrix(rnorm(5000), 500, 10) e1[, 6:10] <- e1[, 6:10]+3 boxplot(e1) e2 <- normalize.totsum(x = e1) boxplot(e2)
A wrapper function of all column-wise normalization methods
normalizeColWise( x, method = c("Median centering", "Median centering (shared ID)", "Total sum", "median centering + variance stablization")[1] )
normalizeColWise( x, method = c("Median centering", "Median centering (shared ID)", "Total sum", "median centering + variance stablization")[1] )
x |
an expression matrix where rows are features and columns are samples, usually log transformed. |
method |
normalization method to use
"Median centering" - median centering, see |
a normalized matrix
e1 <- matrix(rnorm(5000), 100, 50)+10 boxplot(e1) e2 <- normalizeColWise(x = e1, method = "Median centering") boxplot(e2)
e1 <- matrix(rnorm(5000), 100, 50)+10 boxplot(e1) e2 <- normalizeColWise(x = e1, method = "Median centering") boxplot(e2)
A wrapper function of all normalization methods, including row-wise or column-wise normalization.
normalizeData( x, colWise = c("None", "Median centering", "Median centering (shared ID)", "Total sum", "median centering + variance stablization")[1], rowWise = c("None", "Reference", "Batch mean", "Batch reference")[1], ref = NULL, batch = NULL )
normalizeData( x, colWise = c("None", "Median centering", "Median centering (shared ID)", "Total sum", "median centering + variance stablization")[1], rowWise = c("None", "Reference", "Batch mean", "Batch reference")[1], ref = NULL, batch = NULL )
x |
an expression matrix where rows are features and columns are samples, usually log transformed. |
colWise |
column-wise normalization method to use, see |
rowWise |
row-wise normalization method to used
|
ref |
index of reference samples |
batch |
batch factor |
a normalized matrix
e1 <- matrix(rnorm(5000), 100, 50)+10 boxplot(e1) e2 <- normalizeData(x = e1, ref = seq(5, 45, by = 10), rowWise = "Reference") boxplot(e2)
e1 <- matrix(rnorm(5000), 100, 50)+10 boxplot(e1) e2 <- normalizeData(x = e1, ref = seq(5, 45, by = 10), rowWise = "Reference") boxplot(e2)
Start omicsViewer
omicsViewer( dir, additionalTabs = NULL, filePattern = ".(RDS|DB|SQLITE|SQLITE3)$", ESVObj = NULL, esetLoader = readESVObj, exprsGetter = getExprs, pDataGetter = getPData, fDataGetter = getFData, defaultAxisGetter = getAx, appName = "omicsViewer", appVersion = packageVersion("omicsViewer") )
omicsViewer( dir, additionalTabs = NULL, filePattern = ".(RDS|DB|SQLITE|SQLITE3)$", ESVObj = NULL, esetLoader = readESVObj, exprsGetter = getExprs, pDataGetter = getPData, fDataGetter = getFData, defaultAxisGetter = getAx, appName = "omicsViewer", appVersion = packageVersion("omicsViewer") )
dir |
directory to the |
additionalTabs |
additional tabs added to "Analyst" panel |
filePattern |
file pattern to be displayed. |
ESVObj |
the ESV object |
esetLoader |
function to load the eset object, if an RDS file, should be "readRDS" |
exprsGetter |
function to get the expression matrix from eset |
pDataGetter |
function to get the phenotype data from eset |
fDataGetter |
function to get the feature data from eset |
defaultAxisGetter |
function to get the default axes to be visualized. It should be a function with two arguments: x - the object loaded to the viewer; what - one of "sx", "sy", "fx" and "fy", representing the sample space x-axis, sample space y-axis, feature space x-axis and feature space y-axis respectively. |
appName |
name of the application |
appVersion |
version of the application |
do not return values
1 ## To start the shiny app: # omicsViewer( # system.file("extdata", package = "omicsViewer") # )
1 ## To start the shiny app: # omicsViewer( # system.file("extdata", package = "omicsViewer") # )
Extract function annotation from uniprot .dat file
parseDatTerm(file, outputDir = NULL, ...)
parseDatTerm(file, outputDir = NULL, ...)
file |
the .dat or .dat.gz file |
outputDir |
dir of output file |
... |
other parameters passed to readLines |
a data.frame parse from .dat file
Shiny module for boxplot using plotly - Module
plot_roc_pr_module( input, output, session, reactive_param, reactive_checkpoint = reactive(TRUE) )
plot_roc_pr_module( input, output, session, reactive_param, reactive_checkpoint = reactive(TRUE) )
input |
input |
output |
output |
session |
session |
reactive_param |
reactive value; argument pass to draw_roc_pr |
reactive_checkpoint |
reactive_value; check this value before render any plot/executing any calculation |
do not return any values
if (interactive()) { library(shiny) ui <- fluidPage( sliderInput("ngrp", label = "Number of groups", min = 2, max = 5, value = 2), plot_roc_pr_ui("testplot") ) server <- function(input, output, session) { ng <- reactive( sample(letters[1:input$ngrp], size = 100, replace = TRUE) ) callModule( plot_roc_pr_module, id = "testplot", reactive_param = reactive(list( x = ng(), y = rnorm(100) )) ) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( sliderInput("ngrp", label = "Number of groups", min = 2, max = 5, value = 2), plot_roc_pr_ui("testplot") ) server <- function(input, output, session) { ng <- reactive( sample(letters[1:input$ngrp], size = 100, replace = TRUE) ) callModule( plot_roc_pr_module, id = "testplot", reactive_param = reactive(list( x = ng(), y = rnorm(100) )) ) } shinyApp(ui, server) }
Draw dose-response curves
plotDC(mod, ylab = "Abundance", lty = 2, pch = 19, cex = 1, logx = FALSE)
plotDC(mod, ylab = "Abundance", lty = 2, pch = 19, cex = 1, logx = FALSE)
mod |
an |
ylab |
ylab in plot function |
lty |
lty in plot function |
pch |
pch in plot function |
cex |
cex in plot function |
logx |
whether the x-axis should be in log scale |
Draw dose response curve given the feature Data/rowData, phenotype data/colData and expression matrix. The function is usually used in shinyApp.
plotDCMat( expr, pd, fd, featid, dose.var, curve.var = NULL, only.par = FALSE, ... )
plotDCMat( expr, pd, fd, featid, dose.var, curve.var = NULL, only.par = FALSE, ... )
expr |
expression matrix |
pd |
phenotype data or colData |
fd |
feature data or rowData |
featid |
feature id to be visualized |
dose.var |
the column header indicating the dose/time/concentration |
curve.var |
the column header indicating the curve ids |
only.par |
logical value. If true, no plot generated, the function only returns the parameters of models. |
... |
other parameters passed to |
Shiny module for boxplot using plotly - Module
plotly_boxplot_module( input, output, session, reactive_param_plotly_boxplot, reactive_checkpoint = reactive(TRUE) )
plotly_boxplot_module( input, output, session, reactive_param_plotly_boxplot, reactive_checkpoint = reactive(TRUE) )
input |
input |
output |
output |
session |
session |
reactive_param_plotly_boxplot |
reactive value; argument passed to plotly_boxplot |
reactive_checkpoint |
reactive_value; check this value before render any plot/executing any calculation |
do not return any values
if (interactive()) { library(shiny) ui <- fluidPage( plotly_boxplot_ui("testplotly") ) server <- function(input, output, session) { x <- cbind(matrix(rnorm(10000, mean = 3), 1000, 10), matrix(rnorm(20000), 1000, 20)) x[sample(1:length(x), size = 0.3*length(x))] <- NA rownames(x) <- paste("R", 1:nrow(x), sep = "") colnames(x) <- paste("C", 1:ncol(x), sep = "") callModule(plotly_boxplot_module, id = "testplotly", reactive_param_plotly_boxplot = reactive(list( x = x# , i = c(4, 20, 80)# , highlight = c(1, 4, 5, 20), extvar = 1:30 )) ) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( plotly_boxplot_ui("testplotly") ) server <- function(input, output, session) { x <- cbind(matrix(rnorm(10000, mean = 3), 1000, 10), matrix(rnorm(20000), 1000, 20)) x[sample(1:length(x), size = 0.3*length(x))] <- NA rownames(x) <- paste("R", 1:nrow(x), sep = "") colnames(x) <- paste("C", 1:ncol(x), sep = "") callModule(plotly_boxplot_module, id = "testplotly", reactive_param_plotly_boxplot = reactive(list( x = x# , i = c(4, 20, 80)# , highlight = c(1, 4, 5, 20), extvar = 1:30 )) ) } shinyApp(ui, server) }
Function should only be used for the developers
plotly_boxplot_ui(id)
plotly_boxplot_ui(id)
id |
id |
a tagList of UI components
a tagList of UI components
if (interactive()) { library(shiny) ui <- fluidPage( plotly_boxplot_ui("testplotly") ) server <- function(input, output, session) { x <- cbind(matrix(rnorm(10000, mean = 3), 1000, 10), matrix(rnorm(20000), 1000, 20)) x[sample(1:length(x), size = 0.3*length(x))] <- NA rownames(x) <- paste("R", 1:nrow(x), sep = "") colnames(x) <- paste("C", 1:ncol(x), sep = "") callModule(plotly_boxplot_module, id = "testplotly", reactive_param_plotly_boxplot = reactive(list( x = x# , i = c(4, 20, 80)# , highlight = c(1, 4, 5, 20), extvar = 1:30 )) ) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( plotly_boxplot_ui("testplotly") ) server <- function(input, output, session) { x <- cbind(matrix(rnorm(10000, mean = 3), 1000, 10), matrix(rnorm(20000), 1000, 20)) x[sample(1:length(x), size = 0.3*length(x))] <- NA rownames(x) <- paste("R", 1:nrow(x), sep = "") colnames(x) <- paste("C", 1:ncol(x), sep = "") callModule(plotly_boxplot_module, id = "testplotly", reactive_param_plotly_boxplot = reactive(list( x = x# , i = c(4, 20, 80)# , highlight = c(1, 4, 5, 20), extvar = 1:30 )) ) } shinyApp(ui, server) }
Function should only be used for the developers
plotly_scatter_module( input, output, session, reactive_param_plotly_scatter, reactive_regLine = reactive(FALSE), reactive_checkpoint = reactive(TRUE), htest_var1 = reactive(NULL), htest_var2 = reactive(NULL) )
plotly_scatter_module( input, output, session, reactive_param_plotly_scatter, reactive_regLine = reactive(FALSE), reactive_checkpoint = reactive(TRUE), htest_var1 = reactive(NULL), htest_var2 = reactive(NULL) )
input |
input |
output |
output |
session |
sesion |
reactive_param_plotly_scatter |
reactive parammeters for plotly_scatter |
reactive_regLine |
logical show or hide the regression line |
reactive_checkpoint |
checkpoint |
htest_var1 |
when the plot is a beeswarmplot, two groups could be selected for two group comparison, this argument gives the default value. Mainly used for restoring the saved session. |
htest_var2 |
see above |
a list containing the information about the selected data points
an reactive object containing the information of selected, brushed points.
if (interactive()) { library(shiny) # two random variables x <- rnorm(30) y <- x + rnorm(30, sd = 0.5) # variables mapped to color, shape and size cc <- sample(letters[1:4], replace = TRUE, size = 30) shape <- sample(c("S1", "S2", "S3"), replace = TRUE, size = 30) sz <- sample(c(10, 20, 30, replace = TRUE, size = 30)) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", # reactive_checkpoint = reactive(FALSE), reactive_param_plotly_scatter = reactive(list( x = x, y = y, color = cc, shape = shape, size = sz, tooltips = paste("A", 1:30) ))) observe(print(v())) } shinyApp(ui, server) # example beeswarm horizontal x <- rnorm(30) y <- sample(c("x", "y", "z"), size = 30, replace = TRUE) shinyApp(ui, server) # example beeswarm vertical x <- sample(c("x", "y", "z"), size = 30, replace = TRUE) y <- rnorm(30) shinyApp(ui, server) # return values x <- c(5, 6, 3, 4, 1, 2) y <- c(5, 6, 3, 4, 1, 2) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", reactive_param_plotly_scatter = reactive(list( x = x, y = y, tooltips = paste("A", 1:6), highlight = 2:4 ))) observe(print(v())) } shinyApp(ui, server) }
if (interactive()) { library(shiny) # two random variables x <- rnorm(30) y <- x + rnorm(30, sd = 0.5) # variables mapped to color, shape and size cc <- sample(letters[1:4], replace = TRUE, size = 30) shape <- sample(c("S1", "S2", "S3"), replace = TRUE, size = 30) sz <- sample(c(10, 20, 30, replace = TRUE, size = 30)) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", # reactive_checkpoint = reactive(FALSE), reactive_param_plotly_scatter = reactive(list( x = x, y = y, color = cc, shape = shape, size = sz, tooltips = paste("A", 1:30) ))) observe(print(v())) } shinyApp(ui, server) # example beeswarm horizontal x <- rnorm(30) y <- sample(c("x", "y", "z"), size = 30, replace = TRUE) shinyApp(ui, server) # example beeswarm vertical x <- sample(c("x", "y", "z"), size = 30, replace = TRUE) y <- rnorm(30) shinyApp(ui, server) # return values x <- c(5, 6, 3, 4, 1, 2) y <- c(5, 6, 3, 4, 1, 2) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", reactive_param_plotly_scatter = reactive(list( x = x, y = y, tooltips = paste("A", 1:6), highlight = 2:4 ))) observe(print(v())) } shinyApp(ui, server) }
Function should only be used for the developers
plotly_scatter_ui(id, height = "400px")
plotly_scatter_ui(id, height = "400px")
id |
id |
height |
figure height |
a tagList of UI components
if (interactive()) { library(shiny) # two random variables x <- rnorm(30) y <- x + rnorm(30, sd = 0.5) # variables mapped to color, shape and size cc <- sample(letters[1:4], replace = TRUE, size = 30) shape <- sample(c("S1", "S2", "S3"), replace = TRUE, size = 30) sz <- sample(c(10, 20, 30, replace = TRUE, size = 30)) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", # reactive_checkpoint = reactive(FALSE), reactive_param_plotly_scatter = reactive(list( x = x, y = y, color = cc, shape = shape, size = sz, tooltips = paste("A", 1:30) ))) observe(print(v())) } shinyApp(ui, server) # example beeswarm horizontal x <- rnorm(30) y <- sample(c("x", "y", "z"), size = 30, replace = TRUE) shinyApp(ui, server) # example beeswarm vertical x <- sample(c("x", "y", "z"), size = 30, replace = TRUE) y <- rnorm(30) shinyApp(ui, server) # return values x <- c(5, 6, 3, 4, 1, 2) y <- c(5, 6, 3, 4, 1, 2) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", reactive_param_plotly_scatter = reactive(list( x = x, y = y, tooltips = paste("A", 1:6), highlight = 2:4 ))) observe(print(v())) } shinyApp(ui, server) }
if (interactive()) { library(shiny) # two random variables x <- rnorm(30) y <- x + rnorm(30, sd = 0.5) # variables mapped to color, shape and size cc <- sample(letters[1:4], replace = TRUE, size = 30) shape <- sample(c("S1", "S2", "S3"), replace = TRUE, size = 30) sz <- sample(c(10, 20, 30, replace = TRUE, size = 30)) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", # reactive_checkpoint = reactive(FALSE), reactive_param_plotly_scatter = reactive(list( x = x, y = y, color = cc, shape = shape, size = sz, tooltips = paste("A", 1:30) ))) observe(print(v())) } shinyApp(ui, server) # example beeswarm horizontal x <- rnorm(30) y <- sample(c("x", "y", "z"), size = 30, replace = TRUE) shinyApp(ui, server) # example beeswarm vertical x <- sample(c("x", "y", "z"), size = 30, replace = TRUE) y <- rnorm(30) shinyApp(ui, server) # return values x <- c(5, 6, 3, 4, 1, 2) y <- c(5, 6, 3, 4, 1, 2) ui <- fluidPage( plotly_scatter_ui("test_scatter") ) server <- function(input, output, session) { v <- callModule(plotly_scatter_module, id = "test_scatter", reactive_param_plotly_scatter = reactive(list( x = x, y = y, tooltips = paste("A", 1:6), highlight = 2:4 ))) observe(print(v())) } shinyApp(ui, server) }
This is a convenience function to prepare the data to be visualized using omicsViewer
.
The result of PCA and t-test could be included directly.
prepOmicsViewer( expr, pData, fData, PCA = TRUE, ncomp = min(8, ncol(expr)), pca.fillNA = TRUE, t.test = NULL, ttest.fillNA = FALSE, ..., gs = NULL, stringDB = NULL, surv = NULL, SummarizedExperiment = TRUE )
prepOmicsViewer( expr, pData, fData, PCA = TRUE, ncomp = min(8, ncol(expr)), pca.fillNA = TRUE, t.test = NULL, ttest.fillNA = FALSE, ..., gs = NULL, stringDB = NULL, surv = NULL, SummarizedExperiment = TRUE )
expr |
expression matrix where the rows are feature and columns are samples, matrix should be log10 transformed and have unique row and column names |
pData |
phenotype data |
fData |
feature data |
PCA |
pca |
ncomp |
number of components to keep |
pca.fillNA |
logical, whether the NA should be filled with a constant in PCA. |
t.test |
will be passed to the |
ttest.fillNA |
logical, whether the NA should be filled with a constant in t-test. |
... |
arguments passed to |
gs |
gene-set data, please refer to examples for more details about the format |
stringDB |
the IDs that can be used in the STRING database (https://string-db.org/) query. |
surv |
survival data, please refer to examples for more details about the format |
SummarizedExperiment |
logical; whether to return an object of class |
an object of ExpressionSet
or SummarizedExperiment
that can be visualized using
omicsViewer
packdir <- system.file("extdata", package = "omicsViewer") # reading expression expr <- read.delim(file.path(packdir, "expressionMatrix.tsv"), stringsAsFactors = FALSE) colnames(expr) <- make.names(colnames(expr)) rownames(expr) <- make.names(rownames(expr)) # reading feature data fd <- read.delim(file.path(packdir, "featureGeneral.tsv"), stringsAsFactors = FALSE) # reading phenotype data pd <- read.delim(file.path(packdir, "sampleGeneral.tsv"), stringsAsFactors = FALSE) # reading other datasets drugData <- read.delim(file.path(packdir, "sampleDrug.tsv")) # survival data # this data is from cell line, the survival data are fake data to # show how to use the survival data in #' omicsViewer surv <- read.delim(file.path(packdir, "sampleSurv.tsv")) # gene set information genesets <- read_gmt(file.path(packdir, "geneset.gmt"), data.frame = TRUE) gsannot <- gsAnnotIdList(idList = rownames(fd), gsIdMap = genesets, data.frame = TRUE) # Define t-test to be done, a matrix nx3 # every row define a t-test, the format # [column header] [group 1 in the test] [group 2 in the test] tests <- rbind( c("Origin", "RE", "ME"), c("Origin", "RE", "LE"), c('TP53.Status', "MT", "WT") ) # prepare column for stringDB query strid <- sapply(strsplit(fd$Protein.ID, ";|-"), "[", 1) ### d <- prepOmicsViewer( expr = expr, pData = pd, fData = fd, PCA = TRUE, pca.fillNA = TRUE, t.test = tests, ttest.fillNA = FALSE, gs = gsannot, stringDB = strid, surv = surv) # feature space - default x axis attr(d, "fx") <- "ttest|RE_vs_ME|mean.diff" # feature space - default y axis attr(d, "fy") <- "ttest|RE_vs_ME|log.fdr" # sample space - default x axis attr(d, "sx") <- "PCA|All|PC1(" # sample space - default y axis attr(d, "sy") <- "PCA|All|PC2(" # Save object and view # saveRDS(d, file = "dtest.RDS") ## to open the viewer # omicsViewer("./")
packdir <- system.file("extdata", package = "omicsViewer") # reading expression expr <- read.delim(file.path(packdir, "expressionMatrix.tsv"), stringsAsFactors = FALSE) colnames(expr) <- make.names(colnames(expr)) rownames(expr) <- make.names(rownames(expr)) # reading feature data fd <- read.delim(file.path(packdir, "featureGeneral.tsv"), stringsAsFactors = FALSE) # reading phenotype data pd <- read.delim(file.path(packdir, "sampleGeneral.tsv"), stringsAsFactors = FALSE) # reading other datasets drugData <- read.delim(file.path(packdir, "sampleDrug.tsv")) # survival data # this data is from cell line, the survival data are fake data to # show how to use the survival data in #' omicsViewer surv <- read.delim(file.path(packdir, "sampleSurv.tsv")) # gene set information genesets <- read_gmt(file.path(packdir, "geneset.gmt"), data.frame = TRUE) gsannot <- gsAnnotIdList(idList = rownames(fd), gsIdMap = genesets, data.frame = TRUE) # Define t-test to be done, a matrix nx3 # every row define a t-test, the format # [column header] [group 1 in the test] [group 2 in the test] tests <- rbind( c("Origin", "RE", "ME"), c("Origin", "RE", "LE"), c('TP53.Status', "MT", "WT") ) # prepare column for stringDB query strid <- sapply(strsplit(fd$Protein.ID, ";|-"), "[", 1) ### d <- prepOmicsViewer( expr = expr, pData = pd, fData = fd, PCA = TRUE, pca.fillNA = TRUE, t.test = tests, ttest.fillNA = FALSE, gs = gsannot, stringDB = strid, surv = surv) # feature space - default x axis attr(d, "fx") <- "ttest|RE_vs_ME|mean.diff" # feature space - default y axis attr(d, "fy") <- "ttest|RE_vs_ME|log.fdr" # sample space - default x axis attr(d, "sx") <- "PCA|All|PC1(" # sample space - default y axis attr(d, "sy") <- "PCA|All|PC2(" # Save object and view # saveRDS(d, file = "dtest.RDS") ## to open the viewer # omicsViewer("./")
Frequently the .gmt files are downloaed from MSigDB database
read_gmt(x, id = NA, data.frame = FALSE)
read_gmt(x, id = NA, data.frame = FALSE)
x |
the name/path of the gmt file to be read |
id |
the id used in gene sets, if is not NA, it should be either "SYMBOL" or "ENTREZ". Usually only used when reading the .gmt file downloaded from MSigDB. |
data.frame |
logical; whether to organize the data in |
a list or data frame of gene set. When data.frame = TRUE, the returned
object is a data.frame
with two columns: id and term.
file <- system.file("extdata", package = "omicsViewer") file <- file.path(file, "geneset.gmt") gs <- read_gmt(file)
file <- system.file("extdata", package = "omicsViewer") file <- file.path(file, "geneset.gmt") gs <- read_gmt(file)
A convenience function to read the proteinGroups table of MaxQuant output. The function organize the result into different tables, e.g. iBAQ.
read.proteinGroups(x, quant = c("LF", "TMT")[1])
read.proteinGroups(x, quant = c("LF", "TMT")[1])
x |
the proteinGroup.txt file returned by MaxQuant search |
quant |
the quantification method, LF or TMT |
a list of tables extracted from proteinGroups.txt file
Read protein groups output of maxquant output and split it to columns
read.proteinGroups.lf(file)
read.proteinGroups.lf(file)
file |
Maxquant proteinGroup.txt file path |
a list of tables extracted from proteinGroups.txt file
This function accept a path to a sqlite database or RDS object. If an RDS file to be read,
The function is similar to readRDS
. It reads the object to R working environment and perform extra two things.
1. If the loaded data an class of SummarizedExperiment
, it will be converted to ExpressionSet
;
2. If the gene set annotatio is in matrix format, the gene set annotation is converted to data.frame
format.
readESVObj(x)
readESVObj(x)
x |
the path of an object of |
an object of class ExpressionSet
or SummarizedExperiment
to be visualzied.
file <- system.file("extdata/demo.RDS", package = "omicsViewer") obj <- readESVObj(file)
file <- system.file("extdata/demo.RDS", package = "omicsViewer") obj <- readESVObj(file)
This normalization removes the variance in reference samples. The method do not need to specific the batch assignment but cannot work with data contains less than five common reference samples. A typical use of this normalization is to correct some drifting effect in mass spec based label free proteomics or untargeted metabolomics experiment. Usually, this is a very strong normalization should only be used with good reasons.
removeVarQC(x, ref, positive = TRUE, ...)
removeVarQC(x, ref, positive = TRUE, ...)
x |
an expression matrix |
ref |
the index of reference samples |
positive |
logical; force only positive values in the resulted matrix |
... |
if given, |
a normalized matrix
e1 <- matrix(rnorm(5000), 100, 50)+10 e2 <- removeVarQC(x = e1, ref = seq(5, 45, by = 10)) boxplot(e2)
e1 <- matrix(rnorm(5000), 100, 50)+10 e2 <- removeVarQC(x = e1, ref = seq(5, 45, by = 10)) boxplot(e2)
Row-wise normalization of expression matrix with or without reference sample
rowshift(x, batch, ref = NULL, useMean = FALSE)
rowshift(x, batch, ref = NULL, useMean = FALSE)
x |
an expression matrix where rows are features, e.g. genes, proteins and columns are samples. The values in the matrix are usually log transformed. |
batch |
a factor or vector has the same length as |
ref |
a logical vector has the same length as |
useMean |
logical; whether to use means of batches, usually set to TRUE when no reference available |
a matrix (hopefully without/with less batch effect)
e1 <- matrix(rnorm(5000), 500, 10) e1[, 6:10] <- e1[, 6:10] + 3 boxplot(e1) f <- rep(c("a", "b"), each = 5) e2 <- rowshift(x = e1, batch = f) boxplot(e2)
e1 <- matrix(rnorm(5000), 500, 10) e1[, 6:10] <- e1[, 6:10] + 3 boxplot(e1) f <- rep(c("a", "b"), each = 5) e2 <- rowshift(x = e1, batch = f) boxplot(e2)
Save the xcmsViewer result object as sqlite database
saveOmicsViewerDb(obj, db.file, overwrite = TRUE) ## S4 method for signature 'SummarizedExperiment,character' saveOmicsViewerDb(obj, db.file, overwrite = TRUE) ## S4 method for signature 'ExpressionSet,character' saveOmicsViewerDb(obj, db.file, overwrite = TRUE)
saveOmicsViewerDb(obj, db.file, overwrite = TRUE) ## S4 method for signature 'SummarizedExperiment,character' saveOmicsViewerDb(obj, db.file, overwrite = TRUE) ## S4 method for signature 'ExpressionSet,character' saveOmicsViewerDb(obj, db.file, overwrite = TRUE)
obj |
an object of class ExpressionSet or SummarizedExperiment |
db.file |
a character indicate file name of the database file |
overwrite |
logical. whether the database should be overwritten if exist already. |
the directory where the database saved
f <- system.file("extdata", "demo.RDS", package = "omicsViewer") es <- readRDS(f) # The following line will write a database file on your disk # saveOmicsViewerDb(es, db.file = "./omicsViewerData.db")
f <- system.file("extdata", "demo.RDS", package = "omicsViewer") es <- readRDS(f) # The following line will write a database file on your disk # saveOmicsViewerDb(es, db.file = "./omicsViewerData.db")
The selector is used to select columns of phenotype and feature data. Function should only be used for the developers.
triselector_module( input, output, session, reactive_x, reactive_selector1 = reactive(NULL), reactive_selector2 = reactive(NULL), reactive_selector3 = reactive(NULL), label = "Group Label:" )
triselector_module( input, output, session, reactive_x, reactive_selector1 = reactive(NULL), reactive_selector2 = reactive(NULL), reactive_selector3 = reactive(NULL), label = "Group Label:" )
input |
input |
output |
output |
session |
session |
reactive_x |
an nx3 matrix |
reactive_selector1 |
default value for selector 1 |
reactive_selector2 |
default value for selector 2 |
reactive_selector3 |
default value for selector 3 |
label |
of the triselector |
an reactive object containing the selected values
if (interactive()) { library(shiny) library(Biobase) file <- system.file("extdata/demo.RDS", package = "omicsViewer") dat <- readRDS(file) fData <- fData(dat) triset <- stringr::str_split_fixed(colnames(fData), '\\|', n= 3) ui <- fluidPage( triselector_ui("tres"), triselector_ui("tres2") ) server <- function(input, output, session) { v1 <- callModule(triselector_module, id = "tres", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("mean.diff") ) v2 <- callModule(triselector_module, id = "tres2", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("log.fdr")) observe({ print("/////////////////////////") print(v1()) }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) library(Biobase) file <- system.file("extdata/demo.RDS", package = "omicsViewer") dat <- readRDS(file) fData <- fData(dat) triset <- stringr::str_split_fixed(colnames(fData), '\\|', n= 3) ui <- fluidPage( triselector_ui("tres"), triselector_ui("tres2") ) server <- function(input, output, session) { v1 <- callModule(triselector_module, id = "tres", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("mean.diff") ) v2 <- callModule(triselector_module, id = "tres2", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("log.fdr")) observe({ print("/////////////////////////") print(v1()) }) } shinyApp(ui, server) }
Function should only be used for the developers
triselector_ui(id, right_margin = "20")
triselector_ui(id, right_margin = "20")
id |
id |
right_margin |
margin on the right side, in px. For example, "20" translates to "20px". |
a tagList of UI components
if (interactive()) { library(shiny) library(Biobase) file <- system.file("extdata/demo.RDS", package = "omicsViewer") dat <- readRDS(file) fData <- fData(dat) triset <- stringr::str_split_fixed(colnames(fData), '\\|', n= 3) ui <- fluidPage( triselector_ui("tres"), triselector_ui("tres2") ) server <- function(input, output, session) { v1 <- callModule(triselector_module, id = "tres", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("mean.diff") ) v2 <- callModule(triselector_module, id = "tres2", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("log.fdr")) observe({ print("/////////////////////////") print(v1()) }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) library(Biobase) file <- system.file("extdata/demo.RDS", package = "omicsViewer") dat <- readRDS(file) fData <- fData(dat) triset <- stringr::str_split_fixed(colnames(fData), '\\|', n= 3) ui <- fluidPage( triselector_ui("tres"), triselector_ui("tres2") ) server <- function(input, output, session) { v1 <- callModule(triselector_module, id = "tres", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("mean.diff") ) v2 <- callModule(triselector_module, id = "tres2", reactive_x = reactive(triset), reactive_selector1 = reactive("ttest"), reactive_selector2 = reactive("RE_vs_ME"), reactive_selector3 = reactive("log.fdr")) observe({ print("/////////////////////////") print(v1()) }) } shinyApp(ui, server) }
only used inside reactive
trisetter(meta, expr = NULL, combine)
trisetter(meta, expr = NULL, combine)
meta |
a meta data, usually either phenotype data or feature data |
expr |
expression matrix, optional. |
combine |
how the meta and expression to be combined. Should be either "pheno" or "feature' or "none". |
a nx3 matrix
a data.frame
with 3 columns
MQ folder validator Validate whether a folder is a MQ output folder
validMQFolder(dir)
validMQFolder(dir)
dir |
the directory to check |
from the root level, these files exist: mqpar.xml [[combined/]txt/]proteinGroups.txt
a list containing the info about MQ folder check
variable selector
varSelector(x, expr, meta, alternative = NULL)
varSelector(x, expr, meta, alternative = NULL)
x |
variable return by triselector, a list of length three named as "analysis", "subset" and "variable' |
expr |
the expression matrix |
meta |
a meta matrix |
alternative |
alternative value to be returned when nothing to select |
the selected values in input argument x