| Title: | Implementation of Functions to Analyze Nanostring and Other Data for DGE and to Generate Heatmaps |
|---|---|
| Description: | Package for data extraction from Nanostring GeoMx DSP data, also works for other data. Simple functions for Differential Expression Analysis. User-friendly and highly customizable functions for heatmap generation. |
| Authors: | Leonie Johanna Lancelle [aut, cre] (ORCID: <https://orcid.org/0009-0004-3138-0752>) |
| Maintainer: | Leonie Johanna Lancelle <[email protected]> |
| License: | GPL-3 + file LICENSE |
| Version: | 0.99.0 |
| Built: | 2026-07-21 14:46:38 UTC |
| Source: | https://github.com/BiocStaging/DgeaHeatmap |
Build a matrix from an input csv file, with one column as rownames
add_demoElem(demoData)add_demoElem(demoData)
demoData |
A NanostringGeoMxSet object. |
A NanostringGeoMxSet object.
demoData <- readRDS( system.file( "extdata", "miniGeoMx.rds", package = "DgeaHeatmap" ) ) demoData <- add_demoElem(demoData)demoData <- readRDS( system.file( "extdata", "miniGeoMx.rds", package = "DgeaHeatmap" ) ) demoData <- add_demoElem(demoData)
Creating a color scheme based on the available color palettes of RColorBrewer for the heatmap.
adv_Heatmap( ncounts_matrix, column_name = "Heatmap", colorPalette = NULL, cluster_method = "hierarchical", distance_method = "euclidean", cluster_rows = TRUE, cluster_columns = FALSE, k_row = NULL, k_col = NULL, sample_metadata = NULL, annotation_colors = NULL, annotation_name_side = "right", show_row_names = FALSE, show_column_names = TRUE, row_annotation = FALSE, row_annotation_method = "auto", row_anno_names = NULL, row_anno_number = 5, fontsize_title = 15, fontsize_rowAnnotation = 10, fontsize_columnNames = 6, fontsize_rowNames = 4, fontsize_cluster_labels = 8, fontsize_group_annotation = 8, fontsize_group_annotation_legend = 10, fontsize_group_annotation_labels = 8, fontsize_heatmap_legend = 10, fontsize_heatmap_legend_labels = 8, title_heatmapLegend = "Expression", WidthNum = 4.5, HeightNum = 3, UnitSize = "cm" )adv_Heatmap( ncounts_matrix, column_name = "Heatmap", colorPalette = NULL, cluster_method = "hierarchical", distance_method = "euclidean", cluster_rows = TRUE, cluster_columns = FALSE, k_row = NULL, k_col = NULL, sample_metadata = NULL, annotation_colors = NULL, annotation_name_side = "right", show_row_names = FALSE, show_column_names = TRUE, row_annotation = FALSE, row_annotation_method = "auto", row_anno_names = NULL, row_anno_number = 5, fontsize_title = 15, fontsize_rowAnnotation = 10, fontsize_columnNames = 6, fontsize_rowNames = 4, fontsize_cluster_labels = 8, fontsize_group_annotation = 8, fontsize_group_annotation_legend = 10, fontsize_group_annotation_labels = 8, fontsize_heatmap_legend = 10, fontsize_heatmap_legend_labels = 8, title_heatmapLegend = "Expression", WidthNum = 4.5, HeightNum = 3, UnitSize = "cm" )
ncounts_matrix |
An input matrix to create the heatmap. |
column_name |
A string to set the title of the heatmap, default <- "Heatmap". |
colorPalette |
Name of the colorPalette used for the heatmap, default <- NULL. |
cluster_method |
A string setting the cluster method for the heatmap, default <- "hierarchical". |
distance_method |
A string setting the distance method for clustering, default <- "euclidean". |
cluster_rows |
A Boolean switching the optional clustering of the rows on and off, default <- TRUE. |
cluster_columns |
A Boolean switching the optional clustering of the columns on and off, default <- FALSE. |
k_row |
An integer used to set number of clusters for row clustering in the heatmap, default <- NULL. |
k_col |
An integer used to set number of clusters for column clustering in the heatmap, default <- NULL. |
sample_metadata |
A dataframe containing the metadata information for the grouping of the columns, default <- NULL. |
annotation_colors |
A list assigning choosen colors to the corresponding groups, default <- NULL. |
annotation_name_side |
The side of the column annotation description, default <- "right". |
show_row_names |
A Boolean switching rownames on the heatmap on and off, default <- FALSE. |
show_column_names |
A Boolean switching colum names on the heatmap on and off, default <- TRUE. |
row_annotation |
A Boolean switching row annotation on the heatmap on and off, default <- FALSE. |
row_annotation_method |
A string setting the annotation method of the heatmap, default <- "auto". |
row_anno_names |
A list containing choosen rownames to use for the row annotation, default <- NULL. |
row_anno_number |
An integer setting the number of automatic annotations assigned per cluster, default <- 5. |
fontsize_title |
An integer setting the font size of the heatmap title. |
fontsize_rowAnnotation |
An integer setting the font size of the optional row annotation, default <- 10. |
fontsize_columnNames |
An integer setting the font size of the column names, default <- 6. |
fontsize_rowNames |
An integer setting the font size of the row names, default <- 4. |
fontsize_cluster_labels |
An integer setting the font size of the cluster labels, default <- 8. |
fontsize_group_annotation |
An integer setting the font size of the group annotation title, default <- 8. |
fontsize_group_annotation_legend |
An integer setting the font size of the group annotation legend name, default <- 10. |
fontsize_group_annotation_labels |
An integer setting the font size of the group annotation labels in the legend, default <- 8. |
fontsize_heatmap_legend |
An integer setting the font size of the heatmap legend title, default <- 10. |
fontsize_heatmap_legend_labels |
An integer setting the font size of the heatmap legend labels, default <- 8. |
title_heatmapLegend |
A string setting the changeable title of the legend, default "Expression". |
WidthNum |
A float setting the width of the heatmap, default <- 4.5. |
HeightNum |
A float setting the height of the heatmap, default <- 3. |
UnitSize |
A string such as "cm" or "inch" to set the unit of HeightNum and WidthNum, default <- "cm". |
An advanced and customizable heatmap.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed(1) adv_Heatmap(ncounts_matrix)x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed(1) adv_Heatmap(ncounts_matrix)
Function for automatized quality control.
aExprsDataQC(demoData, vFlags)aExprsDataQC(demoData, vFlags)
demoData |
A NanostringGeoMxSet object, storing all expression, annotation, and probe information linked together. |
vFlags |
Character string to set the flags for quality control. |
A matrix.
demoData <- file vFlags <- "QCFlags"demoData <- file vFlags <- "QCFlags"
Builds a matrix from an input csv file, with one column as rownames
build_matrix(counts_data, x)build_matrix(counts_data, x)
counts_data |
A data frame with floats or integers that has strings in one column. |
x |
Number of column which contains the rownames description. |
A matrix.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x)x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x)
Function to set color scheme for a heatmap.
color_setting(colorPalette)color_setting(colorPalette)
colorPalette |
Chosen color palette. |
No return.
colorPalette <- "RdBu" color_setting(colorPalette)colorPalette <- "RdBu" color_setting(colorPalette)
Setting the column clustering
column_clustering( ncounts_matrix, cluster_columns = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_col = NULL, col_split = NULL, col_dend = TRUE )column_clustering( ncounts_matrix, cluster_columns = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_col = NULL, col_split = NULL, col_dend = TRUE )
ncounts_matrix |
An input matrix to create the clustering. |
cluster_columns |
A Boolean switching the optional clustering of the rows on and off, default <- TRUE. |
cluster_method |
A string setting the cluster method for the heatmap. |
distance_method |
A string setting the distance method for clustering. |
k_col |
An integer used to set number of clusters for row clustering. |
col_split |
An integer seeting the column clustering by kmeans. |
col_dend |
A Boolean switching column clustering by hierarchical clustering on (default). |
col_split where the rows are split into clusters
x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed col_split <- NULL col_dend <- TRUE columns_clustered <- column_clustering(ncounts_matrix, cluster_columns = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_col = NULL, col_split = col_split, col_dend = col_dend )x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed col_split <- NULL col_dend <- TRUE columns_clustered <- column_clustering(ncounts_matrix, cluster_columns = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_col = NULL, col_split = col_split, col_dend = col_dend )
Creates a contrast matrix for edgeR
create_contrast_matrix_edgeR(metadata, comparisons = NULL, prefix = "DEA")create_contrast_matrix_edgeR(metadata, comparisons = NULL, prefix = "DEA")
metadata |
A dataframe containing the meta data information of the raw counts matrix. |
comparisons |
An element of the class list, that contains optional information on specific comparisons that are to be conducted (simplifies the results). |
prefix |
A string used as a prefix for the contrast_names that are generated. |
A matrix containing the contrasts for DEA with edgeR.
rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) prefix <- "DEA" results_edgeR <- DGEAedgeR( rawCounts, metadata, grouping_columns, comparisons, prefix = "DEA" ) contrast_matrix <- create_contrast_matrix_edgeR( metadata = metadata, comparisons = comparisons, prefix = prefix )rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) prefix <- "DEA" results_edgeR <- DGEAedgeR( rawCounts, metadata, grouping_columns, comparisons, prefix = "DEA" ) contrast_matrix <- create_contrast_matrix_edgeR( metadata = metadata, comparisons = comparisons, prefix = prefix )
Performs a differential expression analysis based on DESeq2
DGEADESeq2(rawCounts, metadata, grouping_columns, comparisons)DGEADESeq2(rawCounts, metadata, grouping_columns, comparisons)
rawCounts |
A matrix containing raw counts (integers). |
metadata |
A dataframe containing the meta data information of the raw counts matrix. |
grouping_columns |
A list of the columns names in the metadata file that are used to generate the groups for the DEA that are compared with each other. |
comparisons |
An element of the class list, that contains optional information on specific comparisons that are to be conducted (simplifies the results). |
A list containing the voom data, fitting of the linear model, results of the contrasts, and the generated design.
set.seed(1) counts <- matrix(rnbinom(80, mu = 20, size = 1), ncol = 4) colnames(counts) <- paste0("Sample", 1:4) rownames(counts) <- paste0("Gene", 1:20) storage.mode(counts) <- "integer" metadata <- data.frame( segment = factor(rep(c("A", "B"), each = 2)), row.names = colnames(counts) ) comparisons <- list( Comp1 = c("A", "B") ) results_DESeq2 <- DGEADESeq2( rawCounts = counts, metadata = metadata, grouping_columns = "segment", comparisons = comparisons )set.seed(1) counts <- matrix(rnbinom(80, mu = 20, size = 1), ncol = 4) colnames(counts) <- paste0("Sample", 1:4) rownames(counts) <- paste0("Gene", 1:20) storage.mode(counts) <- "integer" metadata <- data.frame( segment = factor(rep(c("A", "B"), each = 2)), row.names = colnames(counts) ) comparisons <- list( Comp1 = c("A", "B") ) results_DESeq2 <- DGEADESeq2( rawCounts = counts, metadata = metadata, grouping_columns = "segment", comparisons = comparisons )
Performs a differential expression analysis based on edgeR
DGEAedgeR( rawCounts, metadata, grouping_columns, comparisons = NULL, prefix = "DEA" )DGEAedgeR( rawCounts, metadata, grouping_columns, comparisons = NULL, prefix = "DEA" )
rawCounts |
A matrix containing raw counts (integers). |
metadata |
A dataframe containing the meta data information of the raw counts matrix. |
grouping_columns |
A list of the columns names in the metadata file that are used to generate groups for the DEA that are compared with each other. |
comparisons |
An element of the class list, that contains optional information on specific comparisons that are to be conducted (simplifies the results). |
prefix |
A string used as a prefix for the contrast_names that are generated. |
A list containing the voom data, fitting of the linear model, results of the contrasts, and the generated design.
set.seed(1) counts <- matrix(rnbinom(600, mu = 10, size = 1), ncol = 6) colnames(counts) <- paste0("Sample", 1:6) rownames(counts) <- paste0("Gene", 1:100) # Create simple metadata metadata <- data.frame( segment = factor(rep(c("A", "B"), each = 3)), row.names = colnames(counts) ) comparisons <- list( Comp1 = c("A", "B") ) results_edgeR <- DGEAedgeR( rawCounts = counts, metadata = metadata, grouping_columns = "segment", comparisons = comparisons, prefix = "DEA" ) names(results_edgeR)set.seed(1) counts <- matrix(rnbinom(600, mu = 10, size = 1), ncol = 6) colnames(counts) <- paste0("Sample", 1:6) rownames(counts) <- paste0("Gene", 1:100) # Create simple metadata metadata <- data.frame( segment = factor(rep(c("A", "B"), each = 3)), row.names = colnames(counts) ) comparisons <- list( Comp1 = c("A", "B") ) results_edgeR <- DGEAedgeR( rawCounts = counts, metadata = metadata, grouping_columns = "segment", comparisons = comparisons, prefix = "DEA" ) names(results_edgeR)
Performs a differential expression analysis based on limma voom
DGEALimma( rawCounts, metadata, grouping_columns, comparisons = NULL, prefix = "DEA" )DGEALimma( rawCounts, metadata, grouping_columns, comparisons = NULL, prefix = "DEA" )
rawCounts |
A matrix containing raw counts (integers). |
metadata |
A dataframe containing the meta data information of the raw counts matrix. |
grouping_columns |
A list of the columns names in the metadata file that are used to generate the groups for the DEA that are compared with each other. |
comparisons |
An element of the class list, that contains optional information on specific comparisons that are to be conducted (simplifies the results). |
prefix |
A string used as a prefix for the contrast_names that are generated. |
A list containing the voom data, fitting of the linear model, results of the contrasts, and the generated design.
rawCounts <- read.csv( system.file("extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" ) ) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file("extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list(Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c( "neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4" )) prefix <- "DEA" DGEAListResults <- DGEALimma( rawCounts, metadata, grouping_columns, comparisons, prefix )rawCounts <- read.csv( system.file("extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" ) ) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file("extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list(Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c( "neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4" )) prefix <- "DEA" DGEAListResults <- DGEALimma( rawCounts, metadata, grouping_columns, comparisons, prefix )
Draw the advanced heatmap
draw_adv_heatmap( ncounts_matrix, column_name = "Heatmap", colorPalette = NULL, col_ha = NULL, show_row_names = FALSE, show_column_names = TRUE, fontsize_title = 15, fontsize_columnNames = 6, fontsize_rowNames = 4, fontsize_cluster_labels = 8, fontsize_heatmap_legend = 10, fontsize_heatmap_legend_labels = 8, title_heatmapLegend = "Expression", WidthNum = 4.5, HeightNum = 3, UnitSize = "cm", row_annotation = FALSE, annotation_for_rows = NULL, row_split = NULL, col_split = NULL, row_dend = TRUE, col_dend = TRUE )draw_adv_heatmap( ncounts_matrix, column_name = "Heatmap", colorPalette = NULL, col_ha = NULL, show_row_names = FALSE, show_column_names = TRUE, fontsize_title = 15, fontsize_columnNames = 6, fontsize_rowNames = 4, fontsize_cluster_labels = 8, fontsize_heatmap_legend = 10, fontsize_heatmap_legend_labels = 8, title_heatmapLegend = "Expression", WidthNum = 4.5, HeightNum = 3, UnitSize = "cm", row_annotation = FALSE, annotation_for_rows = NULL, row_split = NULL, col_split = NULL, row_dend = TRUE, col_dend = TRUE )
ncounts_matrix |
An input matrix to create the heatmap. |
column_name |
A string to set the title of the heatmap. |
colorPalette |
Name of the colorPalette used for the heatmap, default <- NULL. |
col_ha |
A "HeamapAnnotation" object if "sample_metadata" is provided, otherwise NULL. |
show_row_names |
A Boolean switching rownames on the heatmap on and off, default <- FALSE. |
show_column_names |
A Boolean switching colum names on the heatmap on and off, default <- TRUE. |
fontsize_title |
An integer setting the font size of the heatmap title, default <- 15. |
fontsize_columnNames |
An integer setting the font size of the column names, default <- 6. |
fontsize_rowNames |
An integer setting the font size of the row names, default <- 4. |
fontsize_cluster_labels |
An integer setting the font size of the cluster labels, default <- 8. |
fontsize_heatmap_legend |
An integer setting the font size of the heatmap legend title, default <- 10. |
fontsize_heatmap_legend_labels |
An integer setting the font size of the heatmap legend labels, default <- 8. |
title_heatmapLegend |
A string setting the changeable title of the legend, default "Expression". |
WidthNum |
A float setting the width of the heatmap, default <- 4.5. |
HeightNum |
A float setting the height of the heatmap, default <- 3. |
UnitSize |
A string such as "cm" or "inch" to set the unit of HeightNum and WidthNum, default <- "cm". |
row_annotation |
A Boolean switching row annotation on the heatmap on and off, default <- FALSE. |
annotation_for_rows |
Numeric index from matrix for the row annotation |
row_split |
An integer seeting the row clustering by kmeans. |
col_split |
An integer seeting the column clustering by kmeans. |
row_dend |
A Boolean switching row clustering by hierarchical clustering on (default). |
col_dend |
A Boolean switching column clustering by hierarchical clustering on (default). |
Row annotation
set.seed(1) mat <- matrix( rnorm(25), nrow = 5, dimnames = list( paste0("Gene", 1:5), paste0("Sample", 1:5) ) ) sample_metadata <- data.frame( Group = rep(c("A", "B"), length.out = 5), row.names = colnames(mat) ) group_colors <- list( Group = c(A = "#1b9e77", B = "#7570b3") ) col_ha <- set_sample_annotation( sample_metadata = sample_metadata, annotation_colors = group_colors ) ht <- draw_adv_heatmap(mat)set.seed(1) mat <- matrix( rnorm(25), nrow = 5, dimnames = list( paste0("Gene", 1:5), paste0("Sample", 1:5) ) ) sample_metadata <- data.frame( Group = rep(c("A", "B"), length.out = 5), row.names = colnames(mat) ) group_colors <- list( Group = c(A = "#1b9e77", B = "#7570b3") ) col_ha <- set_sample_annotation( sample_metadata = sample_metadata, annotation_colors = group_colors ) ht <- draw_adv_heatmap(mat)
Function to create an elbow plot to choose k for clustering by k-Means.
elbow_plot(top_genes_matrix, maxK = 15)elbow_plot(top_genes_matrix, maxK = 15)
top_genes_matrix |
A matrix for which the best number of clusters in k-Means Clustering is supposed to be calculated. |
maxK |
An integer determining the maximum number of possible clusters. |
An elbow plot to choose k.
x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) scaled_counts <- scale_counts(matrixCounts) top_genes_matrix <- scaled_counts set.seed(seed) elbow_plot(top_genes_matrix)x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) scaled_counts <- scale_counts(matrixCounts) top_genes_matrix <- scaled_counts set.seed(seed) elbow_plot(top_genes_matrix)
Get list of genes and their direction of regulation
extract_genes_direction( results_list, only_up = FALSE, only_down = FALSE, only_sig = FALSE, padj = NULL, padj_cutoff = 0.05, lfc_cutoff = 0 )extract_genes_direction( results_list, only_up = FALSE, only_down = FALSE, only_sig = FALSE, padj = NULL, padj_cutoff = 0.05, lfc_cutoff = 0 )
results_list |
A list containing the results of the DEA. |
only_up |
A Boolean opting for only up regulated genes. |
only_down |
A Boolean opting for only down regulated genes. |
only_sig |
A Boolean opting for only significantly regulated genes. |
padj |
A Float, defining the adjusted p-value. |
padj_cutoff |
A Float, setting the adjusted p-values cutoff. |
lfc_cutoff |
A Float, setting the fold change cutoff. |
A character vector of contrast names.
rawCounts <- read.csv( system.file("extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" ) ) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file("extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) storage.mode(rawCounts) <- "integer" sum(!is.finite(as.matrix(rawCounts))) results_list_DESeq2 <- DGEADESeq2( rawCounts, metadata, grouping_columns, comparisons ) results_list <- results_list_DESeq2$results gene_list <- extract_genes_direction( results_list, only_up = TRUE, only_down = FALSE, only_sig = FALSE, padj = NULL, padj_cutoff = 0.05, lfc_cutoff = 0 )rawCounts <- read.csv( system.file("extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" ) ) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file("extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) storage.mode(rawCounts) <- "integer" sum(!is.finite(as.matrix(rawCounts))) results_list_DESeq2 <- DGEADESeq2( rawCounts, metadata, grouping_columns, comparisons ) results_list <- results_list_DESeq2$results gene_list <- extract_genes_direction( results_list, only_up = TRUE, only_down = FALSE, only_sig = FALSE, padj = NULL, padj_cutoff = 0.05, lfc_cutoff = 0 )
Extracts the results of the DEA with DESeq2
extractDEGenes( results_list, comparisons, only_up = FALSE, only_down = FALSE, up_down = FALSE, only_sig = FALSE, padj_cutoff = 0.05, lfc_cutoff = 0 )extractDEGenes( results_list, comparisons, only_up = FALSE, only_down = FALSE, up_down = FALSE, only_sig = FALSE, padj_cutoff = 0.05, lfc_cutoff = 0 )
results_list |
A list containing the results of the DEA. |
comparisons |
An element of the class list, that contains optional information on specific comparisons that are to be conducted (simplifies the results). |
only_up |
A Boolean opting for only up regulated genes. |
only_down |
A Boolean opting for only down regulated genes. |
up_down |
A Boolean opting for only up and down regulated genes. |
only_sig |
A Boolean opting for only significantly regulated genes. |
padj_cutoff |
A Float, setting the adjusted p-values cutoff. |
lfc_cutoff |
A Float, setting the fold change cutoff. |
A list containing the voom data, fitting of the linear model, results of the contrasts, and the generated design.
rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) storage.mode(rawCounts) <- "integer" sum(!is.finite(as.matrix(rawCounts))) results_list_DESeq2 <- DGEADESeq2( rawCounts, metadata, grouping_columns, comparisons ) results_list <- results_list_DESeq2$results down_genes <- extractDEGenes(results_list, comparisons, only_down = TRUE)rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) storage.mode(rawCounts) <- "integer" sum(!is.finite(as.matrix(rawCounts))) results_list_DESeq2 <- DGEADESeq2( rawCounts, metadata, grouping_columns, comparisons ) results_list <- results_list_DESeq2$results down_genes <- extractDEGenes(results_list, comparisons, only_down = TRUE)
Function to filter a matrix to extract a chosen number of most variable rows through calculation of the variance.
filtering_for_top_exprGenes(counts_data, top_number_of_genes)filtering_for_top_exprGenes(counts_data, top_number_of_genes)
counts_data |
An input matrix from which the most variable rows are to be extracted. |
top_number_of_genes |
An integer to set the number of how many rows should be extracted from the original matrix by variance. |
A new matrix containing only the top_number_of_genes count of rows with the highest variance from input matrix.
x <- 1 top_number_of_genes <- 20 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) counts_data <- matrixCounts varGenesMatrix <- filtering_for_top_exprGenes( counts_data, top_number_of_genes )x <- 1 top_number_of_genes <- 20 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) counts_data <- matrixCounts varGenesMatrix <- filtering_for_top_exprGenes( counts_data, top_number_of_genes )
Creating a heatmap with annotation of x most variable rows(genes).
function_complexHeatmap_var( topGenes_matrix, probes, number_of_annotations_per_cluster, k, Title, fontsize_rowAnnotation, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )function_complexHeatmap_var( topGenes_matrix, probes, number_of_annotations_per_cluster, k, Title, fontsize_rowAnnotation, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )
topGenes_matrix |
An input matrix to create the heatmap. |
probes |
A list of strings to summarize biological replicated in the columns. |
number_of_annotations_per_cluster |
An integer used to set the number of annotations per cluster in the heatmap. |
k |
An integer used to set number of cluster in the heatmap. |
Title |
A string to set the title of the heatmap. |
fontsize_rowAnnotation |
An integer used to set the font size of the row annotation in the heatmap |
fontsize_columnNames |
An integer used to set the font size of the columns in the heatmap. |
fontsize_rowNames |
An integer used to set the font size of the rownames in the heatmap. |
title_heatmapLegend |
A string setting the title of the legend of the heatmap. |
WidthNum |
A float setting the width of the heatmap. |
HeightNum |
A float setting the height of the heatmap. |
UnitSize |
A string such as "cm" or "inch" to set the unit of HeightNum and WidthNum. |
color_Palette |
Name of the colorPalette used for the heatmap. |
A plotted heatmap of the input data.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) topGenes_matrix <- scale_counts(matrixCounts) probes <- list("disease3", "disease4", "disease1B") k <- 1 seed <- 1 fontsize_rowAnnotation <- 8 number_of_annotations_per_cluster <- 5 Title <- "Heatmap of Data" fontsize_columnNames <- 6 fontsize_rowNames <- 4 title_heatmapLegend <- "Expression" WidthNum <- 4.5 HeightNum <- 3 UnitSize <- "cm" color_Palette <- "RdBu" set.seed(seed) function_complexHeatmap_var( topGenes_matrix, probes, number_of_annotations_per_cluster, k, Title, fontsize_rowAnnotation, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) topGenes_matrix <- scale_counts(matrixCounts) probes <- list("disease3", "disease4", "disease1B") k <- 1 seed <- 1 fontsize_rowAnnotation <- 8 number_of_annotations_per_cluster <- 5 Title <- "Heatmap of Data" fontsize_columnNames <- 6 fontsize_rowNames <- 4 title_heatmapLegend <- "Expression" WidthNum <- 4.5 HeightNum <- 3 UnitSize <- "cm" color_Palette <- "RdBu" set.seed(seed) function_complexHeatmap_var( topGenes_matrix, probes, number_of_annotations_per_cluster, k, Title, fontsize_rowAnnotation, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )
Function to generating a raw read count table.
genRawReadCountTable(demoData)genRawReadCountTable(demoData)
demoData |
A NanostringGeoMxSet object, storing all expression, annotation, and probe information linked together. |
A dataframe containing only the raw read counts that have passed quality control.
demoData <- readRDS( system.file( "extdata", "miniGeoMx.rds", package = "DgeaHeatmap" ) ) demoData <- add_demoElem(demoData) NanoStringNCTools::assayDataApply( demoData, MARGIN = 1, FUN = mean, elt = "demoElem" )[seq_len(5)] demoData <- split_data_by_column( demoData, vGroup = "aoi", vElt = "demoElem" ) df_Exp <- genRawReadCountTable(demoData)demoData <- readRDS( system.file( "extdata", "miniGeoMx.rds", package = "DgeaHeatmap" ) ) demoData <- add_demoElem(demoData) NanoStringNCTools::assayDataApply( demoData, MARGIN = 1, FUN = mean, elt = "demoElem" )[seq_len(5)] demoData <- split_data_by_column( demoData, vGroup = "aoi", vElt = "demoElem" ) df_Exp <- genRawReadCountTable(demoData)
Calculates the distance matrix
get_dist(x, method)get_dist(x, method)
x |
An input matrix to create the distance matrix. |
method |
Astring setting the distance method for clustering. |
A distance matrix.
input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) x <- 1 matrixCounts <- build_matrix(input_data, x) matrix <- scale_counts(matrixCounts) method <- "euclidean" distance_matrix <- get_dist(matrix, method)input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) x <- 1 matrixCounts <- build_matrix(input_data, x) matrix <- scale_counts(matrixCounts) method <- "euclidean" distance_matrix <- get_dist(matrix, method)
Creating a color scheme based on the available color palettes of RColorBrewer for the heatmap.
get_heatmap_colors(colorPalette)get_heatmap_colors(colorPalette)
colorPalette |
An input string defining the color palette (available from RColorBrewer). |
The colors used in heatmap based on either ComplexHeatmap default or RColorBrewer.
colorPalette <- "RdBu" get_heatmap_colors(colorPalette)colorPalette <- "RdBu" get_heatmap_colors(colorPalette)
Creates a matrix only containing chosen columns of an original matrix with more data.
individual_matrix(factors_for_matrix_devision, mmatrix)individual_matrix(factors_for_matrix_devision, mmatrix)
factors_for_matrix_devision |
A list containing variables used to extract specific columns from the original matrix. |
mmatrix |
A matrix used as input, from which specifically chosen columns are extracted. |
A new matrix containing fewer columns than before, that have previously been specified.
factors_for_individual_matrix <- list("DKD", "glomerulus") x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) indiMatrix <- individual_matrix(factors_for_individual_matrix, matrixCounts)factors_for_individual_matrix <- list("DKD", "glomerulus") x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) indiMatrix <- individual_matrix(factors_for_individual_matrix, matrixCounts)
Generates K-means for the columns and rows of a matrix.
Kmean_generation(m_top_genes_matrix, k)Kmean_generation(m_top_genes_matrix, k)
m_top_genes_matrix |
An input matrix for which they K-Means are calculated next. |
k |
Number k of how many clusters are created. |
All calculated K-Means of the matrix.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) seed <- 1 k <- 1 set.seed(seed) k_means <- Kmean_generation(m_top_genes_matrix, k)x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) seed <- 1 k <- 1 set.seed(seed) k_means <- Kmean_generation(m_top_genes_matrix, k)
Function to determine the most variable genes of each cluster to enable annotation..
most_variable_genes(m_kmeans, number_of_annotations_per_cluster, k)most_variable_genes(m_kmeans, number_of_annotations_per_cluster, k)
m_kmeans |
Matrix of the k-Means for each row in a gene set. |
number_of_annotations_per_cluster |
Number of wanted annotations per cluster. |
k |
Number of clusters. |
A list of the most variable rows (genes) of each cluster.
x <- 1 number_of_annotations_per_cluster <- 5 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) seed <- 1 k <- 1 set.seed(seed) m_kmeans <- Kmean_generation(m_top_genes_matrix, k) top_x_variable_genes <- most_variable_genes( m_kmeans, number_of_annotations_per_cluster, k )x <- 1 number_of_annotations_per_cluster <- 5 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) seed <- 1 k <- 1 set.seed(seed) m_kmeans <- Kmean_generation(m_top_genes_matrix, k) top_x_variable_genes <- most_variable_genes( m_kmeans, number_of_annotations_per_cluster, k )
Create pairwise contrasts
pairwise_contrasts(comparisons, comp_factor, prefix = "Contrast")pairwise_contrasts(comparisons, comp_factor, prefix = "Contrast")
comparisons |
An element of the class list, that contains optional information on specific comparisons that are to be conducted (simplifies the results). |
comp_factor |
A factor, for fallback all pairwise comparison. |
prefix |
A string used as a prefix for the contrast_names that are generated. |
A character vector of contrast names.
rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) comp <- apply( metadata[, grouping_columns, drop = FALSE], 1, paste, collapse = "_" ) comp <- gsub(" ", "_", comp) # Replace spaces with underscores metadata$comp <- make.names(comp) # Clean names for use in model.matrix comp_factor <- factor(metadata$comp) paired_contrasts <- pairwise_contrasts(comparisons, comp_factor)rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) grouping_columns <- c("segment", "region", "class", "slide_name") comparisons <- list( Comp1 = c( "Geometric_Segment_glomerulus_DKD_disease3", "PanCK_tubule_DKD_disease4" ), Comp2 = c("neg_tubule_DKD_disease4", "PanCK_tubule_DKD_disease4") ) comp <- apply( metadata[, grouping_columns, drop = FALSE], 1, paste, collapse = "_" ) comp <- gsub(" ", "_", comp) # Replace spaces with underscores metadata$comp <- make.names(comp) # Clean names for use in model.matrix comp_factor <- factor(metadata$comp) paired_contrasts <- pairwise_contrasts(comparisons, comp_factor)
Function to perform k-Means clustering for a matrix and setting split to split a heatmap into clusters.
performing_kMeans(m_top_genes_matrix, k)performing_kMeans(m_top_genes_matrix, k)
m_top_genes_matrix |
A matrix for which K-Means are calculated. |
k |
Number of clusters for k-Means clustering (chosen by elbow-plot). |
A new dataframe containing information assigning each rows of the input matrix to a cluster.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) k <- 1 split <- performing_kMeans(m_top_genes_matrix, k)x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) k <- 1 split <- performing_kMeans(m_top_genes_matrix, k)
Creates a contrast matrix for edgeR
prepare_dge_list(rawCounts, metadata)prepare_dge_list(rawCounts, metadata)
rawCounts |
A matrix containing raw counts (integers). |
metadata |
A dataframe containing the meta data information of the raw counts matrix, with a column containing the comparison factors. |
A DGEList object.
rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) y <- prepare_dge_list(rawCounts, metadata)rawCounts <- read.csv(system.file( "extdata/RawDataExamplePackageNanostring.csv", package = "DgeaHeatmap" )) rawCounts <- build_matrix(rawCounts, 1) metadata <- readRDS(system.file( "extdata/MetaDataPackageNanostring.rds", package = "DgeaHeatmap" )) y <- prepare_dge_list(rawCounts, metadata)
Function to build a heatmap using other functions.
print_heatmap( m_top_genes_matrix, title, split, anno, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )print_heatmap( m_top_genes_matrix, title, split, anno, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )
m_top_genes_matrix |
An input matrix for which the heatmap is created. |
title |
A string used to set the title of the heatmap. |
split |
A dataframe containing information about the clustering of the rows of the input matrix. |
anno |
A numeric index containing row informations for annotation. |
fontsize_columnNames |
An integer used to set the font size of the columns in the heatmap. |
fontsize_rowNames |
An integer used to set the font size of the rownames in the heatmap. |
title_heatmapLegend |
A string setting the title of the legend of the heatmap. |
WidthNum |
A float setting the width of the heatmap. |
HeightNum |
A float setting the height of the heatmap. |
UnitSize |
A string such as "cm" or "inch" to set the unit of HeightNum and WidthNum. |
color_Palette |
Name of the colorPalette used for the heatmap. |
A plotted heatmap.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) k <- 1 split <- performing_kMeans(m_top_genes_matrix, k) seed <- 1 fontsize_rowAnnotation <- 8 set.seed(seed) m_kmeans <- Kmean_generation(m_top_genes_matrix, k) number_of_annotations_per_cluster <- 5 top_x_genes_cluster <- most_variable_genes( m_kmeans, number_of_annotations_per_cluster, k ) anno <- set_annotation( m_top_genes_matrix, top_x_genes_cluster, fontsize_rowAnnotation ) title <- "Heatmap of Data" fontsize_columnNames <- 6 fontsize_rowNames <- 4 title_heatmapLegend <- "Expression" WidthNum <- 4.5 HeightNum <- 3 UnitSize <- "cm" color_Palette <- "RdBu" set.seed(seed) print_heatmap( m_top_genes_matrix, title, split, anno, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) k <- 1 split <- performing_kMeans(m_top_genes_matrix, k) seed <- 1 fontsize_rowAnnotation <- 8 set.seed(seed) m_kmeans <- Kmean_generation(m_top_genes_matrix, k) number_of_annotations_per_cluster <- 5 top_x_genes_cluster <- most_variable_genes( m_kmeans, number_of_annotations_per_cluster, k ) anno <- set_annotation( m_top_genes_matrix, top_x_genes_cluster, fontsize_rowAnnotation ) title <- "Heatmap of Data" fontsize_columnNames <- 6 fontsize_rowNames <- 4 title_heatmapLegend <- "Expression" WidthNum <- 4.5 HeightNum <- 3 UnitSize <- "cm" color_Palette <- "RdBu" set.seed(seed) print_heatmap( m_top_genes_matrix, title, split, anno, fontsize_columnNames, fontsize_rowNames, title_heatmapLegend, WidthNum, HeightNum, UnitSize, color_Palette )
Setting the row clustering
row_clustering( ncounts_matrix, cluster_rows = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_row = NULL, row_split = NULL, row_dend = TRUE )row_clustering( ncounts_matrix, cluster_rows = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_row = NULL, row_split = NULL, row_dend = TRUE )
ncounts_matrix |
An input matrix to create the clustering. |
cluster_rows |
A Boolean switching the optional clustering of the rows on and off, default <- TRUE. |
cluster_method |
A string setting the cluster method for the heatmap. |
distance_method |
A string setting the distance method for clustering. |
k_row |
An integer used to set number of clusters for row clustering. |
row_split |
An integer seeting the column clustering by kmeans. |
row_dend |
A Boolean switching column clustering by hierarchical clustering on (default). |
row_split where the rows are split into clusters
x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed row_split <- NULL row_dend <- TRUE rows_clustered <- row_clustering(ncounts_matrix, cluster_rows = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_row = NULL, row_split = row_split, row_dend = row_dend )x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed row_split <- NULL row_dend <- TRUE rows_clustered <- row_clustering(ncounts_matrix, cluster_rows = TRUE, cluster_method = "hierarchical", distance_method = "euclidean", k_row = NULL, row_split = row_split, row_dend = row_dend )
Function to Z-count scale the values of a matrix.
scale_counts(countsmatrix)scale_counts(countsmatrix)
countsmatrix |
An input matrix whose values are scaled by Z-count. |
A new matrix with Z-count scaled values.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) countsmatrix <- build_matrix(input_data, x) scaled_counts <- scale_counts(countsmatrix)x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) countsmatrix <- build_matrix(input_data, x) scaled_counts <- scale_counts(countsmatrix)
Function to set row annotation for a heatmap.
set_annotation(m_top_genes_matrix, top_x_genes_cluster, fontsize_rowAnnotation)set_annotation(m_top_genes_matrix, top_x_genes_cluster, fontsize_rowAnnotation)
m_top_genes_matrix |
An input matrix to used for heatmap generation and choosing annotation for a heatmap. |
top_x_genes_cluster |
A list of the most variable x genes of each cluster in a heatmap. |
fontsize_rowAnnotation |
An integer defining the font size of the row annotation |
A numeric index from the orginal matrix.
x <- 1 number_of_annotations_per_cluster <- 5 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) seed <- 1 k <- 1 fontsize_rowAnnotation <- 8 set.seed(seed) m_kmeans <- Kmean_generation(m_top_genes_matrix, k) top_x_genes_cluster <- most_variable_genes( m_kmeans, number_of_annotations_per_cluster, k ) anno <- set_annotation( m_top_genes_matrix, top_x_genes_cluster, fontsize_rowAnnotation )x <- 1 number_of_annotations_per_cluster <- 5 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) m_top_genes_matrix <- scale_counts(matrixCounts) seed <- 1 k <- 1 fontsize_rowAnnotation <- 8 set.seed(seed) m_kmeans <- Kmean_generation(m_top_genes_matrix, k) top_x_genes_cluster <- most_variable_genes( m_kmeans, number_of_annotations_per_cluster, k ) anno <- set_annotation( m_top_genes_matrix, top_x_genes_cluster, fontsize_rowAnnotation )
Setting the row annotation
set_row_annotation( ncounts_matrix, k_row = NULL, row_annotation = FALSE, row_annotation_method = "auto", row_anno_names = NULL, row_anno_number = 5, fontsize_rowAnnotation = 10 )set_row_annotation( ncounts_matrix, k_row = NULL, row_annotation = FALSE, row_annotation_method = "auto", row_anno_names = NULL, row_anno_number = 5, fontsize_rowAnnotation = 10 )
ncounts_matrix |
An input matrix to create the heatmap. |
k_row |
An integer used to set number of clusters for row clustering in the heatmap, default <- NULL. |
row_annotation |
A Boolean switching row annotation on the heatmap on and off, default <- FALSE. |
row_annotation_method |
A string setting the annotation method of the heatmap, default <- "auto". |
row_anno_names |
A list containing choosen rownames to use for the row annotation, default <- NULL. |
row_anno_number |
An integer setting the number of automatic annotations assigned per cluster, default <- 5. |
fontsize_rowAnnotation |
An integer setting the font size of the group annotation labels in the legend, default <- 8. |
Numeric index from matrix for the row annotation
x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed(seed) annotation_for_rows <- set_row_annotation(ncounts_matrix)x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed(seed) annotation_for_rows <- set_row_annotation(ncounts_matrix)
Setting the sample annotation
set_sample_annotation( sample_metadata = NULL, annotation_colors = NULL, annotation_name_side = "right", fontsize_group_annotation = 8, fontsize_group_annotation_legend = 10, fontsize_group_annotation_labels = 8 )set_sample_annotation( sample_metadata = NULL, annotation_colors = NULL, annotation_name_side = "right", fontsize_group_annotation = 8, fontsize_group_annotation_legend = 10, fontsize_group_annotation_labels = 8 )
sample_metadata |
A dataframe containing the metadata information for the grouping of the columns, default <- NULL. |
annotation_colors |
A list assigning choosen colors to the corresponding groups, default <- NULL. |
annotation_name_side |
The side of the column annotation description, default <- "right". |
fontsize_group_annotation |
An integer setting the font size of the group annotation title, default <- 8. |
fontsize_group_annotation_legend |
An integer setting the font size of the group annotation legend name, default <- 10. |
fontsize_group_annotation_labels |
An integer setting the font size of the group annotation labels in the legend, default <- 8. |
A "HeamapAnnotation" object if "sample_metadata" is provided, otherwise NULL.
x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed groups <- c( "3_DKD_glomerulus_Geometric_S", "1B_DKD_glomerulus_Geometric_S", "2B_DKD_glomerulus_WT" ) sample_names <- c(colnames(ncounts_matrix)) group_assignment <- sapply(sample_names, function(sample) { matched <- groups[sapply(groups, function(g) grepl(g, sample))] if (length(matched) > 0) matched[1] else NA }) stopifnot(length(sample_names) == length(group_assignment)) sample_metadata <- data.frame( Group = group_assignment, row.names = sample_names ) all(colnames(ncounts_matrix) == rownames(sample_metadata)) group_colors <- list(Group = c( "3_DKD_glomerulus_Geometric_S" = "#1b9e77", "1B_DKD_glomerulus_Geometric_S" = "#7570b3", "2B_DKD_glomerulus_WT" = "#e7298a" )) col_ha <- set_sample_annotation( sample_metadata = sample_metadata, annotation_colors = group_colors )x <- 1 seed <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) ncounts_matrix <- scale_counts(matrixCounts) set.seed groups <- c( "3_DKD_glomerulus_Geometric_S", "1B_DKD_glomerulus_Geometric_S", "2B_DKD_glomerulus_WT" ) sample_names <- c(colnames(ncounts_matrix)) group_assignment <- sapply(sample_names, function(sample) { matched <- groups[sapply(groups, function(g) grepl(g, sample))] if (length(matched) > 0) matched[1] else NA }) stopifnot(length(sample_names) == length(group_assignment)) sample_metadata <- data.frame( Group = group_assignment, row.names = sample_names ) all(colnames(ncounts_matrix) == rownames(sample_metadata)) group_colors <- list(Group = c( "3_DKD_glomerulus_Geometric_S" = "#1b9e77", "1B_DKD_glomerulus_Geometric_S" = "#7570b3", "2B_DKD_glomerulus_WT" = "#e7298a" )) col_ha <- set_sample_annotation( sample_metadata = sample_metadata, annotation_colors = group_colors )
Function to visualize the data distribution within the data of a matrix.
show_data_distribution(scaled_counts)show_data_distribution(scaled_counts)
scaled_counts |
An input matrix with Z-count scaled values. |
A plot visualizing the data distribution of Z-count scaled data.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) scaled_counts <- scale_counts(matrixCounts) show_data_distribution(scaled_counts)x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) matrixCounts <- build_matrix(input_data, x) scaled_counts <- scale_counts(matrixCounts) show_data_distribution(scaled_counts)
Splitting data by group column with feature, pheno or protocol data to then get the mean.
split_data_by_column(demoData, vGroup, vElt)split_data_by_column(demoData, vGroup, vElt)
demoData |
A NanostringGeoMxSet object, storing all expression, annotation, and probe information linked together. |
vGroup |
Group of features in column. |
vElt |
Character string of the expression matrix name. |
A NanostringGeoMxSet object.
demoData <- readRDS( system.file( "extdata", "miniGeoMx.rds", package = "DgeaHeatmap" ) ) demoData <- add_demoElem(demoData) NanoStringNCTools::assayDataApply( demoData, MARGIN = 1, FUN = mean, elt = "demoElem" )[seq_len(5)] demoData <- split_data_by_column( demoData, vGroup = "aoi", vElt = "demoElem" )demoData <- readRDS( system.file( "extdata", "miniGeoMx.rds", package = "DgeaHeatmap" ) ) demoData <- add_demoElem(demoData) NanoStringNCTools::assayDataApply( demoData, MARGIN = 1, FUN = mean, elt = "demoElem" )[seq_len(5)] demoData <- split_data_by_column( demoData, vGroup = "aoi", vElt = "demoElem" )
Summarizes columns biological replicates of a matrix into one.
summarise_bio_replicates(top_genes_matrix, probes)summarise_bio_replicates(top_genes_matrix, probes)
top_genes_matrix |
An input matrix with columns representing biological replicates. |
probes |
List of strings by which columns of biological replicates can be identified. |
A new matrix where biological replicated are summarized as their mean.
x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) top_genes_matrix <- build_matrix(input_data, x) probes <- list("disease3", "disease4", "disease1B") newMatrix <- summarise_bio_replicates(top_genes_matrix, probes)x <- 1 input_data <- read.csv(system.file("extdata/testfile_counts.csv", package = "DgeaHeatmap" )) top_genes_matrix <- build_matrix(input_data, x) probes <- list("disease3", "disease4", "disease1B") newMatrix <- summarise_bio_replicates(top_genes_matrix, probes)
Summarize the results of the DEA with edgeR
summarize_edgeR_DEA( results_edgeR, lfc_threshold = 1, fdr_threshold = 0.05, return_significant_genes = TRUE )summarize_edgeR_DEA( results_edgeR, lfc_threshold = 1, fdr_threshold = 0.05, return_significant_genes = TRUE )
results_edgeR |
A list containing the results of the DEA. |
lfc_threshold |
A Float, setting threshold value for the fold change. |
fdr_threshold |
A Float, setting the False Discovery Rate threshold. |
return_significant_genes |
A Boolean opting for the output of significantly regulated genes. |
A list containing the voom data, fitting of the linear model, results of the contrasts, and the generated design.
results_edgeR <- readRDS( system.file( "extdata", "mini_edgeR_results.rds", package = "DgeaHeatmap" ) ) summarize_edgeR_DEA(results_edgeR)results_edgeR <- readRDS( system.file( "extdata", "mini_edgeR_results.rds", package = "DgeaHeatmap" ) ) summarize_edgeR_DEA(results_edgeR)