Title: | PolySTest: Detection of differentially regulated features. Combined statistical testing for data with few replicates and missing values |
---|---|
Description: | The complexity of high-throughput quantitative omics experiments often leads to low replicates numbers and many missing values. We implemented a new test to simultaneously consider missing values and quantitative changes, which we combined with well-performing statistical tests for high confidence detection of differentially regulated features. The package contains functions to run the test and to visualize the results. |
Authors: | Veit Schwämmle [aut, cre] |
Maintainer: | Veit Schwämmle <[email protected]> |
License: | GPL-2 |
Version: | 1.1.0 |
Built: | 2024-11-23 03:34:05 UTC |
Source: | https://github.com/bioc/PolySTest |
Performs checks on a SummarizedExperiment object to ensure it is properly formatted for PolySTest analysis. It checks for specific metadata properties, the number of assays, and the distribution of conditions and replicates.
check_for_polystest(se)
check_for_polystest(se)
se |
A SummarizedExperiment object. |
Invisible TRUE if checks pass; otherwise, warnings or errors are thrown.
data(liver_example) check_for_polystest(liver_example)
data(liver_example) check_for_polystest(liver_example)
Verifies if the provided test names and comparison names are correct
and have been executed within the given SummarizedExperiment
object.
It checks for the presence of specific metadata related to the tests
and comparisons to ensure that the requested analyses have been carried out.
check_stat_names(fulldata, compNames, testNames)
check_stat_names(fulldata, compNames, testNames)
fulldata |
A |
compNames |
A character vector of comparison names to be verified
against the |
testNames |
A character vector of statistical test names to be verified
against the |
This function is used to ensure that the requested statistical tests
and comparisons have been correctly named and executed prior to further
analysis. It verifies that the names provided match those stored within the
metadata of the SummarizedExperiment
object. If the names do not match or
the necessary metadata is missing, the function stops execution and returns
an error message indicating the issue.
The function return the updated comparison names if the checks pass.
data(liver_example) compNames <- "all" testNames <- c("limma", "t_test") check_stat_names(liver_example, compNames, testNames)
data(liver_example) compNames <- "all" testNames <- c("limma", "t_test") check_stat_names(liver_example, compNames, testNames)
This function generates a matrix of all pairwise comparisons between the provided conditions. Optionally, a reference condition can be specified, and comparisons will be made between the reference condition and all other conditions.
create_pairwise_comparisons(conditions, refCond)
create_pairwise_comparisons(conditions, refCond)
conditions |
A character vector of condition names. |
refCond |
An integer indicating the index of the reference condition
within the
|
A matrix with two columns, representing all possible pairwise comparisons between the specified conditions. If a reference condition is specified, it appears in the first column of every row.
conditions <- c("Cond1", "Cond2", "Cond3") # Generate all pairwise comparisons allComps <- create_pairwise_comparisons(conditions, refCond = 0) allComps # Generate comparisons with a specific condition as reference refComps <- create_pairwise_comparisons(conditions, refCond = 1) refComps
conditions <- c("Cond1", "Cond2", "Cond3") # Generate all pairwise comparisons allComps <- create_pairwise_comparisons(conditions, refCond = 0) allComps # Generate comparisons with a specific condition as reference refComps <- create_pairwise_comparisons(conditions, refCond = 1) refComps
Function to determine "optimal" fold-change and q-value thresholds using a higher criticism method and an FC threshold based on a standard deviation of one
FindFCandQlimAlternative(Pvalue, LogRatios)
FindFCandQlimAlternative(Pvalue, LogRatios)
Pvalue |
A matrix of p-values for each condition |
LogRatios |
A matrix of log ratios for each condition |
A vector containing the mean fold-change threshold and mean q-value threshold
Pvalue <- matrix(seq(0.01, 0.12, 0.01), nrow = 4, ncol = 3) LogRatios <- matrix(c( 1.2, 0.8, 1.5, -0.5, 0.2, 0.9, -1.1, 0.7, 1.8, -0.9, 0.3, 1.1 ), nrow = 4, ncol = 3) thresholds <- FindFCandQlimAlternative(Pvalue, LogRatios) print(thresholds)
Pvalue <- matrix(seq(0.01, 0.12, 0.01), nrow = 4, ncol = 3) LogRatios <- matrix(c( 1.2, 0.8, 1.5, -0.5, 0.2, 0.9, -1.1, 0.7, 1.8, -0.9, 0.3, 1.1 ), nrow = 4, ncol = 3) thresholds <- FindFCandQlimAlternative(Pvalue, LogRatios) print(thresholds)
This function sets the number of threads for parallel processing. If the environment variable SHINY_THREADS is set, the number of threads is set to the value of SHINY_THREADS.
get_numthreads(threads = NULL)
get_numthreads(threads = NULL)
threads |
An integer indicating the number of threads to use. |
An integer indicating the number of threads to use.
get_numthreads(threads = 4) get_numthreads()
get_numthreads(threads = 4) get_numthreads()
This function performs paired limma analysis on MAData.
limma_paired(MAData, NumCond, NumReps)
limma_paired(MAData, NumCond, NumReps)
MAData |
A ratio matrix of gene expression data. The rows are genes and the columns are samples. Replicates must be grouped together. |
NumCond |
The number of ratios to check vs zero level |
NumReps |
The number of replicates per condition. |
A list containing the p-values and q-values.
MAData <- matrix(rnorm(600), nrow = 100) NumCond <- 3 NumReps <- 2 limma_res <- limma_paired(MAData, NumCond, NumReps) head(limma_res$qlvalues)
MAData <- matrix(rnorm(600), nrow = 100) NumCond <- 3 NumReps <- 2 limma_res <- limma_paired(MAData, NumCond, NumReps) head(limma_res$qlvalues)
This function performs unpaired limma analysis on Data.
limma_unpaired(Data, NumCond, NumReps, RRCateg)
limma_unpaired(Data, NumCond, NumReps, RRCateg)
Data |
A matrix of quantitative expression data. |
NumCond |
The number of conditions in the experiment. |
NumReps |
The number of replicates per condition. |
RRCateg |
A matrix specifying the conditons to be compared (each comparison given as separate column). |
A list containing the following results:
plvalues: The p-values from limma tests.
qlvalues: The q-values from limma tests.
Sds: The standard deviations of the Bayesian linear model. @details This function performs unpaired limma analysis on Data. It calculates the p-values and q-values for each row, indicating the significance of the difference between the two datasets.RRCateg is a matrix specifying the conditons to be compared (each comparison given as separate column). It thus has always 2 rows and n columns, where n is the number of comparisons. The function returns a list containing the p-values and q-values for each comparison, as well as the standard deviations of the Bayesian linear model.
dataMatrix <- matrix(rnorm(900), ncol = 9) NumCond <- 3 NumReps <- 3 colnames(dataMatrix) <- rep(c("A", "B", "C"), each = 3) # Specifying comparisons RRCateg <- matrix(c(1, 2, 2, 3), nrow = 2, ncol = 2) # Run function results <- limma_unpaired(dataMatrix, NumCond, NumReps, RRCateg) print(results$plvalues)
dataMatrix <- matrix(rnorm(900), ncol = 9) NumCond <- 3 NumReps <- 3 colnames(dataMatrix) <- rep(c("A", "B", "C"), each = 3) # Specifying comparisons RRCateg <- matrix(c(1, 2, 2, 3), nrow = 2, ncol = 2) # Run function results <- limma_unpaired(dataMatrix, NumCond, NumReps, RRCateg) print(results$plvalues)
This data set is a SummarizedExperiment object containing liver proteomics of mice fed with four different diets. The data contains 3 replicates per diet (condition). The rowData of the object contains the output from running the PolySTest statistical tests on the data.
A SummarizedExperiment object
A SummarizedExperiment object
Protein expressions from the livers of mice fed with different diets: high fat, TTA component, Fish oil and TTA + fish oil
data(liver_example)
data(liver_example)
Calculates the p-values and q-values for missing values in a data frame with columns as samples and rows as features.
MissingStats(Data, NumCond, NumReps)
MissingStats(Data, NumCond, NumReps)
Data |
A matrix containing the expression data with rows as features and columns as samples |
NumCond |
The number of conditions in the dataset |
NumReps |
The number of replicates for each condition (needs to be same for all conditions) |
A list containing the calculated p-values and q-values (Benjamini-Hochberg) for missingness statistics
Data <- matrix(rnorm(120), nrow = 10) # Introduce some missingness Data[sample(1:120, 40)] <- NA NumCond <- 4 NumReps <- 3 res_misstest <- MissingStats(Data, NumCond, NumReps) head(res_misstest$qNAvalues)
Data <- matrix(rnorm(120), nrow = 10) # Introduce some missingness Data[sample(1:120, 40)] <- NA NumCond <- 4 NumReps <- 3 res_misstest <- MissingStats(Data, NumCond, NumReps) head(res_misstest$qNAvalues)
Function of calculation of Miss tests. This happens between full groups and thus does not have distinction for pairwise testing.
MissingStatsDesign(Data, RRCateg, NumCond, NumReps)
MissingStatsDesign(Data, RRCateg, NumCond, NumReps)
Data |
A matrix containing the expression data with rows as features and columns as samples |
RRCateg |
A matrix containing the indices of the conditions to compare (each row is a pairing) |
NumCond |
The number of conditions in the dataset |
NumReps |
The number of replicates for each condition (needs to be same for all conditions) |
A list containing the calculated p-values and q-values (Benjamini-Hochbeg) for missingness statistics
Data <- matrix(rnorm(120), nrow = 10) # Introduce some missingness Data[sample(seq_len(120), 40)] <- NA RRCateg <- matrix(c(1, 2, 1, 3, 1, 4, 2, 3, 2, 4, 3, 4), nrow = 2, ncol = 6) NumCond <- 4 NumReps <- 3 res_misstest <- MissingStatsDesign(Data, RRCateg, NumCond, NumReps) head(res_misstest$qNAvalues)
Data <- matrix(rnorm(120), nrow = 10) # Introduce some missingness Data[sample(seq_len(120), 40)] <- NA RRCateg <- matrix(c(1, 2, 1, 3, 1, 4, 2, 3, 2, 4, 3, 4), nrow = 2, ncol = 6) NumCond <- 4 NumReps <- 3 res_misstest <- MissingStatsDesign(Data, RRCateg, NumCond, NumReps) head(res_misstest$qNAvalues)
This function calculates the distribution of missing values for a given number of repetitions and percentage of missing values.
MissValPDistr(NumReps, PercNA)
MissValPDistr(NumReps, PercNA)
NumReps |
An integer indicating the number of repetitions. |
PercNA |
A numeric value indicating the percentage of missing values. |
A numeric vector containing the distribution of missing values.
MissValPDistr(10, 0.2)
MissValPDistr(10, 0.2)
This function performs permutation testing for unpaired data. The permutation testing is based on comparing the t-values of the real data with the t-values of the permuted data.
perm_unpaired(tData, trefData)
perm_unpaired(tData, trefData)
tData |
The data matrix for the test group (features are rows). |
trefData |
The data matrix for the reference group (features are rows). |
The function adds columns from the randomized full set to reach the minimum number of permutation columns (NumPermCols) replicates. It randomizes the sign as well to avoid tendencies to one or the other side. In the unpaired case, it also normalizes by the mean of the entire sample to avoid strange effects. The function then performs permutation testing using parallel computing, and calculates the p-values and q-values based on the permutation results. Both groups needs to consist of the same number of samples (columns).
A list containing the p-values and q-values for the permutation test.
tData <- matrix(rnorm(1000), nrow = 100) trefData <- matrix(rnorm(1000), nrow = 100) result <- perm_unpaired(tData, trefData)
tData <- matrix(rnorm(1000), nrow = 100) trefData <- matrix(rnorm(1000), nrow = 100) result <- perm_unpaired(tData, trefData)
This function performs permutation tests on the given tMAData The permutation tests determine an empirical null distribution of t-values for the p-value calculation
permtest_paired(tMAData)
permtest_paired(tMAData)
tMAData |
A matrix of data for running permutation tests |
A list containing the p-values and q-values (Benjamini-Hochberg)
tMAData <- matrix(rnorm(100), nrow = 10) tout <- permtest_paired(tMAData) head(tout$qPermutvalues)
tMAData <- matrix(rnorm(100), nrow = 10) tout <- permtest_paired(tMAData) head(tout$qPermutvalues)
This function plots expression profiles for selected features across different conditions and comparisons. It supports both scaling and unscaled profiles. It adds a circular plot to compare the different statistical tests
plotExpression( fulldata, compNames = "all", testNames = c("PolySTest", "limma", "Miss Test", "rank products", "permutation test", "t-test"), sel_prots = "all", profiles_scale = TRUE, qlim = 0.05, fclim = c(0, 0) )
plotExpression( fulldata, compNames = "all", testNames = c("PolySTest", "limma", "Miss Test", "rank products", "permutation test", "t-test"), sel_prots = "all", profiles_scale = TRUE, qlim = 0.05, fclim = c(0, 0) )
fulldata |
A |
compNames |
A character vector of comparison names. "all" selects all comparisons. |
testNames |
A character vector of test names used in the analysis. Default values are "PolySTest", "limma", "Miss test", "rank products", "permutation test", and "t-test". |
sel_prots |
A numeric vector with the indices of the selected features. Default is "all". These will still be filterd |
profiles_scale |
Logical indicating if profiles should be scaled. Default is TRUE. |
qlim |
A numeric value indicating the q-value limit for significance. |
fclim |
A numeric vector of length 2 indicating fold-change limits. |
Plots expression profiles for the selected features.
data(liver_example) compNames <- c("HF.Rep._vs_TTA.Rep.") plotExpression(liver_example)
data(liver_example) compNames <- c("HF.Rep._vs_TTA.Rep.") plotExpression(liver_example)
This function generates a heatmap for selected features across comparisons using the heatmaply package. It provides options for scaling and saving the plot to a file.
plotHeatmaply( fulldata, sel_prots = "all", heatmap_scale = "none", file = NULL, ... )
plotHeatmaply( fulldata, sel_prots = "all", heatmap_scale = "none", file = NULL, ... )
fulldata |
A |
sel_prots |
Character vector specifying selected features to include in the heatmap or "all" to include all proteins. |
heatmap_scale |
Character, indicating if and how the data should be scaled. Possible values are "none", "row", or "column". |
file |
Optional character string specifying the path to save the heatmap plot. If NULL, the plot is rendered interactively. |
... |
Arguments passed further to heatmaply function |
A plotly object if file
is NULL. Otherwise, the heatmap is saved
to the specified file.
data(liver_example) plotHeatmaply( fulldata = liver_example, sel_prots = "all", heatmap_scale = "row" )
data(liver_example) plotHeatmaply( fulldata = liver_example, sel_prots = "all", heatmap_scale = "row" )
Generates histograms of p-value distributions for each test and comparison.
plotPvalueDistr( fulldata, compNames = "all", testNames = c("limma", "Miss Test", "rank products", "permutation test", "t-test"), testCols = c("#33AAAA", "#33AA33", "#AA3333", "#AA33AA", "#AAAA33", "#3333AA"), ... )
plotPvalueDistr( fulldata, compNames = "all", testNames = c("limma", "Miss Test", "rank products", "permutation test", "t-test"), testCols = c("#33AAAA", "#33AA33", "#AA3333", "#AA33AA", "#AAAA33", "#3333AA"), ... )
fulldata |
A |
compNames |
A character vector of comparison names. "all" selects all comparisons. |
testNames |
A character vector of test names used in the analysis. Default values are "PolySTest", "limma", "Miss test", "rank products", "permutation test", and "t-test". |
testCols |
A character vector of colors for each test. Defaults to c("#33AAAA", "#33AA33", "#AA3333", "#AA33AA", "#AAAA33", "#3333AA"). |
... |
Additional arguments passed to |
Creates histograms of p-value distributions for the specified tests
# Assuming `fulldata` is a properly prepared `SummarizedExperiment` object data(liver_example) plotPvalueDistr(liver_example, compNames = c("HF.Rep._vs_TTA.Rep."), testCols = rainbow(5) )
# Assuming `fulldata` is a properly prepared `SummarizedExperiment` object data(liver_example) plotPvalueDistr(liver_example, compNames = c("HF.Rep._vs_TTA.Rep."), testCols = rainbow(5) )
This function plots the mfrnumber of regulated features across comparisons for different statistical tests. It shows how the number of significant features varies with different FDR thresholds.
plotRegNumber( fulldata, compNames = "all", testNames = c("PolySTest", "limma", "Miss Test", "rank products", "permutation test", "t-test"), qlim = 0.05, fclim = c(0, 0), TestCols = c("#33AAAA", "#33AA33", "#AA3333", "#AA33AA", "#AAAA33", "#3333AA"), ... )
plotRegNumber( fulldata, compNames = "all", testNames = c("PolySTest", "limma", "Miss Test", "rank products", "permutation test", "t-test"), qlim = 0.05, fclim = c(0, 0), TestCols = c("#33AAAA", "#33AA33", "#AA3333", "#AA33AA", "#AAAA33", "#3333AA"), ... )
fulldata |
A |
compNames |
A character vector of comparison names. "all" selects all comparisons. |
testNames |
A character vector of test names used in the analysis. Default values are "PolySTest", "limma", "Miss test", "rank products", "permutation test", and "t-test". |
qlim |
Numeric, q-value (FDR) threshold. |
fclim |
Numeric vector, fold-change limits. |
TestCols |
Character vector, colors to use for each test in the plot. |
... |
Arguments passed further to plot/lines calls |
Invisible. The function generates plots.
data(liver_example) plotRegNumber(fulldata = liver_example, NumComps = 3)
data(liver_example) plotRegNumber(fulldata = liver_example, NumComps = 3)
Visualizes the intersections of significant features across multiple comparisons using an UpSet plot. Summarizes all comparisons from all tests
plotUpset(fulldata, qlim = 0.05, fclim = c(0, 0))
plotUpset(fulldata, qlim = 0.05, fclim = c(0, 0))
fulldata |
A |
qlim |
A numeric value, the q-value threshold for significance. |
fclim |
A numeric vector, specifying fold change limits for filtering. |
An UpSet plot visualizing the intersections of significant features.
data(liver_example) plotUpset(liver_example, qlim = 0.05)
data(liver_example) plotUpset(liver_example, qlim = 0.05)
This function creates volcano plots for all specified statistical tests and
comparisons using data from a SummarizedExperiment
object. It highlights
selected proteins and applies fold-change and q-value limits for
visualization.
plotVolcano( fulldata, compNames = "all", testNames = c("PolySTest", "limma", "Miss Test", "rank products", "permutation test", "t-test"), sel_prots = "all", qlim = 0.05, fclim = c(0, 0), testCols = c("#33AAAA", "#33AA33", "#AA3333", "#AA33AA", "#AAAA33", "#3333AA"), ... )
plotVolcano( fulldata, compNames = "all", testNames = c("PolySTest", "limma", "Miss Test", "rank products", "permutation test", "t-test"), sel_prots = "all", qlim = 0.05, fclim = c(0, 0), testCols = c("#33AAAA", "#33AA33", "#AA3333", "#AA33AA", "#AAAA33", "#3333AA"), ... )
fulldata |
A |
compNames |
A character vector of comparison names. |
testNames |
A character vector of test names including "PolySTest", "limma", "Miss test", "rank products", "permutation test", and "t-test". |
sel_prots |
A numeric vector indicating selected features to be visualized differently or "all" to select all features. Default is "all". |
qlim |
A numeric value setting the q-value limit for the plots. Default is 0.05. |
fclim |
A numeric vector of length two setting the fold-change limits for the plots. Default is c(0,0). |
testCols |
A character vector of colors for each test. Default is a predefined set of colors. |
... |
Additional arguments passed to the plot function. |
Creates volcano plots for the specified tests and comparisons.
data(liver_example) compNames <- c("HF.Rep._vs_TTA.Rep.") plotVolcano(liver_example, compNames)
data(liver_example) compNames <- c("HF.Rep._vs_TTA.Rep.") plotVolcano(liver_example, compNames)
Integrates various statistical tests for analyzing paired data within
a SummarizedExperiment
framework. It compares pairs of conditions
specified by the user to calculate p-values and q-values for each comparison.
PolySTest_paired( fulldata, allComps, statTests = c("limma", "Miss_Test", "t_test", "rank_products", "permutation_test") )
PolySTest_paired( fulldata, allComps, statTests = c("limma", "Miss_Test", "t_test", "rank_products", "permutation_test") )
fulldata |
A |
allComps |
A matrix specifying pairs of conditions to compare. Each row represents a pair for comparison. |
statTests |
A character vector specifying the statistical tests to be applied. Available tests include "limma", "Miss_Test", "t-test", "rank_products", and "permutation_test". The function will perform each specified test and integrate the results. |
Executes specified statistical tests on the dataset contained in
fulldata
using the condition pairs outlined in allComps
.
Calculates p-values and q-values for each genomic feature (e.g.,
genes, proteins) included in the analysis. Results are added to the
rowData
of the
SummarizedExperiment
object, enhancing it with detailed statistics
from the paired tests.
A SummarizedExperiment
object augmented with p-values and q-values
in its rowData
, reflecting the outcomes of the specified
statistical analyses.
library(SummarizedExperiment) # Mock quantitative data and metadata for samples quantData <- matrix(rnorm(2000), nrow = 200, ncol = 10) colnames(quantData) <- c( paste("Sample", 1:5, "_Condition_A", sep = ""), paste("Sample", 1:5, "_Condition_B", sep = "") ) rownames(quantData) <- paste("Gene", 1:200) sampleMetadata <- data.frame(Condition = rep(c("A", "B"), each = 5)) # Creating the SummarizedExperiment object fulldata <- SummarizedExperiment( assays = list(quant = quantData), colData = sampleMetadata ) metadata(fulldata) <- list(NumReps = 5, NumCond = 2) # Specifying pairs of conditions to compare allComps <- matrix(c("A", "B"), ncol = 2, byrow = TRUE) # Specify statistical tests to apply statTests <- c("limma", "t_test", "rank_products") # Running PolySTest for paired comparisons results <- PolySTest_paired(fulldata, allComps, statTests)
library(SummarizedExperiment) # Mock quantitative data and metadata for samples quantData <- matrix(rnorm(2000), nrow = 200, ncol = 10) colnames(quantData) <- c( paste("Sample", 1:5, "_Condition_A", sep = ""), paste("Sample", 1:5, "_Condition_B", sep = "") ) rownames(quantData) <- paste("Gene", 1:200) sampleMetadata <- data.frame(Condition = rep(c("A", "B"), each = 5)) # Creating the SummarizedExperiment object fulldata <- SummarizedExperiment( assays = list(quant = quantData), colData = sampleMetadata ) metadata(fulldata) <- list(NumReps = 5, NumCond = 2) # Specifying pairs of conditions to compare allComps <- matrix(c("A", "B"), ncol = 2, byrow = TRUE) # Specify statistical tests to apply statTests <- c("limma", "t_test", "rank_products") # Running PolySTest for paired comparisons results <- PolySTest_paired(fulldata, allComps, statTests)
Combining the power of different statistical tests
PolySTest_unpaired( fulldata, allComps, statTests = c("limma", "Miss_Test", "t_test", "rank_products", "permutation_test") )
PolySTest_unpaired( fulldata, allComps, statTests = c("limma", "Miss_Test", "t_test", "rank_products", "permutation_test") )
fulldata |
A SummarizedExperiment or derived object that contains the quantitative data as required for PolySTest |
allComps |
A matrix containing the reference matrix specifying the pairs of conditions to compare (each comparison given as separate row) |
statTests |
A character vector specifying the statistical tests to be used. The available tests are: "limma", "Miss_Test", "t-test", "rank_products", and "permutation_test" |
This function performs unpaired statistical tests on the data in 'fulldata' using the pairs of conditions specified in 'allComps'. It calculates the p-values and q-values for each row for the statistical tests used. The statistical tests available are: limma, Miss_Test, t-test, rank_products, and a permutation_test based on t values. The function returns a SummarizedExperiment object with added columns for p-values and q-values in rowData.
SummarizedExperiment with added columns for p-values and q-values in rowData
# Creating mock quantitative data and sample metadata library(SummarizedExperiment) quantData <- matrix(rnorm(2000), nrow = 200, ncol = 10) colnames(quantData) <- c( paste("Sample", seq_len(5), "_Condition_A", sep = ""), paste("Sample", seq_len(5), "_Condition_B", sep = "") ) rownames(quantData) <- paste("Gene", seq_len(200)) sampleMetadata <- data.frame(Condition = rep(c("A", "B"), each = 5)) # Creating the SummarizedExperiment object fulldata <- SummarizedExperiment( assays = list(quant = quantData), colData = sampleMetadata ) metadata(fulldata) <- list(NumReps = 5, NumCond = 2) # Specifying pairs of conditions to compare allComps <- matrix(c("A", "B"), ncol = 2, byrow = TRUE) # Running the PolySTest_unpaired function results <- PolySTest_unpaired(fulldata, allComps)
# Creating mock quantitative data and sample metadata library(SummarizedExperiment) quantData <- matrix(rnorm(2000), nrow = 200, ncol = 10) colnames(quantData) <- c( paste("Sample", seq_len(5), "_Condition_A", sep = ""), paste("Sample", seq_len(5), "_Condition_B", sep = "") ) rownames(quantData) <- paste("Gene", seq_len(200)) sampleMetadata <- data.frame(Condition = rep(c("A", "B"), each = 5)) # Creating the SummarizedExperiment object fulldata <- SummarizedExperiment( assays = list(quant = quantData), colData = sampleMetadata ) metadata(fulldata) <- list(NumReps = 5, NumCond = 2) # Specifying pairs of conditions to compare allComps <- matrix(c("A", "B"), ncol = 2, byrow = TRUE) # Running the PolySTest_unpaired function results <- PolySTest_unpaired(fulldata, allComps)
Perform unpaired rank products test
rp_unpaired(tData, trefData)
rp_unpaired(tData, trefData)
tData |
The data matrix for the test group (features are rows). |
trefData |
The data matrix for the reference group (features are rows). |
This function calculates the p-values and q-values using rankd product statistics. The function requires having the same number of samples per group. The function uses parallel computing to speed up the calculations.
A list containing the p-values and q-values.
tData <- matrix(rnorm(1000), nrow = 100) trefData <- matrix(rnorm(1000), nrow = 100) rp_unpaired(tData, trefData)
tData <- matrix(rnorm(1000), nrow = 100) trefData <- matrix(rnorm(1000), nrow = 100) rp_unpaired(tData, trefData)
This function calculates the p-values for the RP (Rank Product) statistic based on the input tRPMAData and the number of replicates (NumReps). The statistcs is one-sided, i.e. it only detects up-regulation.
RPStats(tRPMAData, NumReps)
RPStats(tRPMAData, NumReps)
tRPMAData |
A matrix containing the expression data with rows as features and columns as replicates. |
NumReps |
The number of replicates for each feature. |
A numeric vector containing the p-values for the RP statistic.
tRPMAData <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, ncol = 3) NumReps <- 3 RPStats(tRPMAData, NumReps)
tRPMAData <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, ncol = 3) NumReps <- 3 RPStats(tRPMAData, NumReps)
Automatically sets the mfrow
parameter for par()
based on the total
number of plots and the maximum number of columns desired.
set_mfrow(num_total, max_col)
set_mfrow(num_total, max_col)
num_total |
The total number of plots to display. |
max_col |
The maximum number of columns for the layout. |
Sets the mfrow
parameter for par()
.
# This will set the layout to 2 rows of 3 columns set_mfrow(num_total = 6, max_col = 3) for (i in 1:6) hist(1:10) par(mfrow = c(1, 1))
# This will set the layout to 2 rows of 3 columns set_mfrow(num_total = 6, max_col = 3) for (i in 1:6) hist(1:10) par(mfrow = c(1, 1))
This function calculates the statistics for a permutation test based on the input data.
StatsForPermutTest(Data, Paired)
StatsForPermutTest(Data, Paired)
Data |
A matrix or data frame containing the data for the test. |
Paired |
A logical value indicating whether the test is paired or not. |
A numeric vector containing the calculated statistics.
Data <- matrix(rnorm(100), ncol = 10) StatsForPermutTest(Data, Paired = FALSE)
Data <- matrix(rnorm(100), ncol = 10) StatsForPermutTest(Data, Paired = FALSE)
This function performs row-wise paired t-tests on a data frame containing log-fold changes
ttest_paired(tMAData)
ttest_paired(tMAData)
tMAData |
A matrix of data for running row-wise t-tests |
A list containing the p-values and q-values (qvalue package)
tMAData <- matrix(rnorm(1000), nrow = 100) tout <- ttest_paired(tMAData) head(tout$qtvalues)
tMAData <- matrix(rnorm(1000), nrow = 100) tout <- ttest_paired(tMAData) head(tout$qtvalues)
Perform unpaired t-tests on two datasets
ttest_unpaired(tData, trefData)
ttest_unpaired(tData, trefData)
tData |
A matrix or data frame with the quantitative features (via rows) of the first group |
trefData |
A matrix or data frame with the quantitative features (via rows) of the second group |
This function performs unpaired t-tests between corresponding rows of two datasets. It calculates the p-values and q-values for each row, indicating the significance of the difference between the two datasets. We require providing the same number of samples (columns) per group.
A list containing the p-values and q-values for each row
tData <- matrix(rnorm(1000), nrow = 100) trefData <- matrix(rnorm(1000), nrow = 100) result <- ttest_unpaired(tData, trefData) print(result$ptvalues) print(result$qtvalues)
tData <- matrix(rnorm(1000), nrow = 100) trefData <- matrix(rnorm(1000), nrow = 100) result <- ttest_unpaired(tData, trefData) print(result$ptvalues) print(result$qtvalues)
This function iterates over a set of conditions and updates each condition with the longest common subsequence of column names associated with that condition.
update_conditions_with_lcs(fulldata, default = NULL)
update_conditions_with_lcs(fulldata, default = NULL)
fulldata |
A SummarizedExperiment or derived object that contains the quantitative data as specified for PolySTest |
default |
A vector of the length of the number of conditions suggesting their names |
SummarizedExperiment with updated conditions
library(SummarizedExperiment) se <- SummarizedExperiment(assays = list(count = matrix(rnorm(200), ncol = 10 ))) metadata(se) <- list(NumCond = 2, NumReps = 5) rownames(colData(se)) <- paste0( rep(c("CondA_Rep", "CondB_Rep"), 5), rep(seq_len(5), each = 2) ) default_conditions <- c("Condition_A", "Condition_B") updated_conditions <- update_conditions_with_lcs(se, default_conditions) print(colData(updated_conditions))
library(SummarizedExperiment) se <- SummarizedExperiment(assays = list(count = matrix(rnorm(200), ncol = 10 ))) metadata(se) <- list(NumCond = 2, NumReps = 5) rownames(colData(se)) <- paste0( rep(c("CondA_Rep", "CondB_Rep"), 5), rep(seq_len(5), each = 2) ) default_conditions <- c("Condition_A", "Condition_B") updated_conditions <- update_conditions_with_lcs(se, default_conditions) print(colData(updated_conditions))