forked from sebastianlieske/mmRmeta
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
started markdown file
- Loading branch information
1 parent
1bd8bba
commit 09c2934
Showing
10 changed files
with
524,910 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(make.kruskal.frame) | ||
import(data.table) | ||
import(ggplot2) | ||
importFrom(dplyr,group_by_) | ||
importFrom(dplyr,summarize) | ||
importFrom(magrittr,"%>%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#' Plot graphs | ||
#' @description Plot different charts. | ||
#' @param data Input data e.g. data frame | ||
#' @param type Type of graph e.g. ("boxplot", "violinplot", "jitterplot", "barplot") | ||
#' @param x Values for x-axis, e.g. values of a column to be passed to aes(x = ...) of \link{ggplot2} | ||
#' @param y Values for y-axis, values of a column to be passed to aes(y = ...) of \link{ggplot2} | ||
#' @param geom_plot_args A list of rguments to \link{ggplot2} | ||
#' @import ggplot2 | ||
#' @import data.table | ||
#' @examples | ||
#' brainCalculatedMetadata <- calculate.metadata(metadata, brainRows) | ||
#' @return | ||
|
||
plot.graph <- function(data, type = "jitter", x, y, geom_plot_args = list()) { | ||
#check if data is a data table | ||
if (!is.data.table(data)) data <- data.table(data) | ||
if(type == "boxplot") { | ||
ggplot(data, aes(x = data[[x]], y = data[[y]])) + | ||
do.call("geom_boxplot", geom_plot_args) + | ||
xlab(x) + | ||
ylab(y) | ||
} | ||
else if(type == "violinplot") { | ||
ggplot(data, aes(x = data[[x]], y = data[[y]])) + | ||
do.call("geom_violin", geom_plot_args) + | ||
geom_jitter(size = 0.4, width = 0.15) + | ||
stat_summary(fun.data = summary.violin, color = "black") + | ||
xlab(x) + | ||
ylab(y) | ||
} | ||
else if(type == "jitter") { | ||
ggplot(data, aes(x = data[[x]], y = data[[y]])) + | ||
do.call("geom_jitter", geom_plot_args) + | ||
xlab(x) + | ||
ylab(y) | ||
} | ||
else if(type == "barplot") { | ||
ggplot(data, aes(x = data[[x]])) + | ||
do.call("geom_bar", geom_plot_args) + | ||
xlab(x) + | ||
ylab(y) | ||
} | ||
} | ||
|
||
#' Calculation of median + range | ||
#' @param x Input from ggplot | ||
summary.violin <- function(x) { | ||
mu <- mean(x) | ||
sigma1 <- mu-sd(x) | ||
sigma2 <- mu+sd(x) | ||
return(c(y=mu, ymin=sigma1, ymax=sigma2)) | ||
} |
Oops, something went wrong.