Title: | A Collection of Utility Function from the Inserm/Inria SISTM Team |
---|---|
Description: | Functions common to members of the SISTM team. |
Authors: | Boris Hejblum [aut], Mélanie Huchon [aut, cre] |
Maintainer: | Mélanie Huchon <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-12-25 06:47:10 UTC |
Source: | CRAN |
Bland-Altman plot function
BlandAltmanPlot( var1, var2, with_gradient = FALSE, line_color = c("blue", "lightblue"), extremum_pctg = TRUE )
BlandAltmanPlot( var1, var2, with_gradient = FALSE, line_color = c("blue", "lightblue"), extremum_pctg = TRUE )
var1 |
a vector of numerics for the 1rst group to be compared. |
var2 |
a vector of numerics for the 2nd group to be compared. |
with_gradient |
a logical indicating if you have a lot of measures, use |
line_color |
a vector of color for the three lines : average difference and upper and lower limits of the confidence interval for the average difference. |
extremum_pctg |
a logical indicating if you want to add the percentage of points outside the confidence interval for the upper and lower limits. Default is TRUE. |
a ggplot2
object
library(ggplot2) #Small sample #Generate data x <- rnorm(30) y <- rnorm(30, mean = 5, sd = 3) #Plotting BlandAltmanPlot(var1 = x, var2 = y) #Add color by group gr <- c(rep("G1", 15), rep("G2", 15)) BlandAltmanPlot(var1 = x, var2 = y) + geom_point(aes(color = gr)) #High sample #Generate data x <- rnorm(10000) y <- rnorm(10000, mean = 5, sd = 3) #Plotting with gradient BlandAltmanPlot(var1 = x, var2 = y, with_gradient = TRUE)
library(ggplot2) #Small sample #Generate data x <- rnorm(30) y <- rnorm(30, mean = 5, sd = 3) #Plotting BlandAltmanPlot(var1 = x, var2 = y) #Add color by group gr <- c(rep("G1", 15), rep("G2", 15)) BlandAltmanPlot(var1 = x, var2 = y) + geom_point(aes(color = gr)) #High sample #Generate data x <- rnorm(10000) y <- rnorm(10000, mean = 5, sd = 3) #Plotting with gradient BlandAltmanPlot(var1 = x, var2 = y, with_gradient = TRUE)
Multiple boxplots for many times
multipleBoxplots(data, x_var, y_var, add_points = TRUE)
multipleBoxplots(data, x_var, y_var, add_points = TRUE)
data |
a dataset from which the variable |
x_var |
corresponding to the x coordinates for the plot, it must be a factor to obtain multiple boxplots. |
y_var |
corresponding to the y coordinates for the plot. |
add_points |
if you want to add points on boxplots. Default value is |
a ggplot2
object
library(ggplot2) #Generate data x_ex <- factor(c(rep("J0", 10), rep("J7", 10), rep("J14", 10)), levels = c("J0", "J7", "J14")) y_ex <- rnorm(30) data_ex <- cbind.data.frame(x_ex, y_ex) #Plotting multipleBoxplots(data = data_ex, x_var = x_ex, y_var = y_ex) multipleBoxplots(data = data_ex, x_var = x_ex, y_var = y_ex) + labs(x = "Time", y = "Value") + theme(legend.position = "none")
library(ggplot2) #Generate data x_ex <- factor(c(rep("J0", 10), rep("J7", 10), rep("J14", 10)), levels = c("J0", "J7", "J14")) y_ex <- rnorm(30) data_ex <- cbind.data.frame(x_ex, y_ex) #Plotting multipleBoxplots(data = data_ex, x_var = x_ex, y_var = y_ex) multipleBoxplots(data = data_ex, x_var = x_ex, y_var = y_ex) + labs(x = "Time", y = "Value") + theme(legend.position = "none")
Functions
normal_distribution(vec)
normal_distribution(vec)
vec |
a |
a vector
Volcano plot function
volcanoPlot( log2fc, pValue, data, FDR_threshold = 0.05, LFC_threshold = log2(1.5), color = c("red", "black"), geneNames = NULL, nb_geneTags = 20, logTransformPVal = TRUE )
volcanoPlot( log2fc, pValue, data, FDR_threshold = 0.05, LFC_threshold = log2(1.5), color = c("red", "black"), geneNames = NULL, nb_geneTags = 20, logTransformPVal = TRUE )
log2fc |
a magnitude of change (fold-change) in base log 2 corresponding to the x-axis. |
pValue |
a statistical significance (p-value) corresponding to the y-axis. |
data |
a data.frame of differentially expressed results from which the
variable |
FDR_threshold |
a threshold of false discovery rate. |
LFC_threshold |
a threshold of log fold change. |
color |
a vector of two colors for significant or not significant points. |
geneNames |
a vector of gene names if you want to put gene tags on the volcano plot. Default is NULL. |
nb_geneTags |
number of tags for the significant genes if |
logTransformPVal |
If TRUE, the p-values will have a negative logarithm transformation (base 10). Default is TRUE. |
a ggplot2
object
genes <- paste0("G", 1:500) pval <- runif(500, max = 0.5) log2FC <- runif(500, min = -4, max = 4) data <- cbind.data.frame(genes, pval, log2FC) rm(genes, pval, log2FC) volcanoPlot(log2FC, pval, data, geneNames = genes)
genes <- paste0("G", 1:500) pval <- runif(500, max = 0.5) log2FC <- runif(500, min = -4, max = 4) data <- cbind.data.frame(genes, pval, log2FC) rm(genes, pval, log2FC) volcanoPlot(log2FC, pval, data, geneNames = genes)