Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added Rproj/package
  • Loading branch information
sebastianlieske committed Jan 30, 2019
1 parent e69a0c1 commit c5d03d2
Show file tree
Hide file tree
Showing 33 changed files with 559 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
13 changes: 13 additions & 0 deletions DESCRIPTION
@@ -0,0 +1,13 @@
Package: mmRmeta
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person(given = "First",
family = "Last",
role = c("aut", "cre"),
email = "first.last@example.com")
Description: What the package does (one paragraph).
License: What license it uses
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
6 changes: 6 additions & 0 deletions NAMESPACE
@@ -0,0 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(make.kruskal.frame)
importFrom(dplyr,group_by_)
importFrom(dplyr,summarize)
importFrom(magrittr,"%>%")
2 changes: 1 addition & 1 deletion R/add.expression.R
Expand Up @@ -3,7 +3,7 @@
#' @param cancer_data A large list created by multimodalR
#' @param nested_metadata A list of data frames made by >make.nested.metadata<
#' @param key Character or integer - Column name or index of unique identifier of nested_metadata, default = "case_id"
#' @importFrom magittr %>%
#' @importFrom magrittr %>%
#' @examples
#' lungMetaExpression <- add.expression(lungXY, lungMetaExpression)
#' @return Returns the same list but with data franes containing the expression values in a new colummn.
Expand Down
2 changes: 1 addition & 1 deletion R/count.column.R
Expand Up @@ -3,7 +3,7 @@
#' @param df Data frame, in this case meta data of a corresponding gene
#' @param factor_one Character - first grouping factor, a column name of the data frame
#' @param factor_two Character - second grouping factor, a column name of the data frame
#' @importFrom magittr %>%
#' @importFrom magrittr %>%
#' @examples
#' df <- data.frame(case_id = c(1,2,3,4,5,6), group = c("one","one","two","one","two","three"), primary_diagnosis = c("Squamous cell carcinoma, NOS", "Adenocarcinoma, NOS", "Adenocarcinoma with mixed subtypes", "Squamous cell carcinoma, NOS", "Squamous cell carcinoma, NOS", "Squamous cell carcinoma, NOS"))
#' diagnosis_counts <- count.column(df, factor_one = "group", factor_two = "primary_diagnosis")
Expand Down
2 changes: 1 addition & 1 deletion R/counts.per.group.R
Expand Up @@ -4,7 +4,7 @@
#' @param list_df Either a list of data frames or a single data frame
#' @param first_grouping Character - first grouping variable | Default "case_id"
#' @param second_grouping Character - second grouping variable | Default "group""
#' @importFrom magittr %>%
#' @importFrom magrittr %>%
#' @importFrom dplyr group_by_ summarize
#' @examples
#' Using a Data Frame
Expand Down
1 change: 1 addition & 0 deletions R/reorder.column.R
Expand Up @@ -4,6 +4,7 @@
#' @param cancer_data A large list created prior by multimodalR.
#' @param column Character - column name
#' @param remove Integer - threshold of counts; any factor level with equal or less counts are discarded
#' @importFrom magrittr %>%
#' @examples
#' lungMeta <- reorder.colums(lungMeta, "primary_diagnosis", 10) #keeps factor levels with >= 10 counts.
#' @return Returns the same large list with changed column names of the expressionmatrix.
Expand Down
10 changes: 5 additions & 5 deletions R/subset.metadata.R
Expand Up @@ -5,20 +5,20 @@
#' @param key character - Unique identifier, default = "case_id"
#' @param additional_key needs to be added
#' @param additional_value needs to be added
#' @importFrom magittr %>%
#' @importFrom magrittr %>%
#' @examples
#' lungMetaData <- subset.metadata(metadata, lungXY)
#' @return Returns a data table of the metadata for a primary cancer site (organ).

subset.metadata <- function(meta_data, cancer_data, key = "case_id", additional_key = NULL, additional_value = NULL) {
if(!is.character(meta_data[[key]]) {
meta_data[[key]] <- as.character(meta_data[[key]]) #transform factor to character
if(!is.character(meta_data[[key]])) {
meta_data[[key]] <- as.character(meta_data[[key]]) #transform factor to character
}
correctRows <- numeric() #empty vector to be filled later
caseNames <- names(cancer_data$Expressionmatrix) #vector of case_id from expressionmatrix
for (cases in caseNames) { #match case_id of the vector with case_id of metadata
matchedRow <- grep(cases, meta_data[[key]]
correctRows <- c(correctRows, matchedRow)
matchedRow <- grep(cases, meta_data[[key]])
correctRows <- c(correctRows, matchedRow)
}
meta_data <- meta_data[c(correctRows),] #subset by machted case_id
if(!is.null(additional_key)) {
Expand Down
6 changes: 6 additions & 0 deletions R/summary.plots.R
@@ -1,6 +1,12 @@

summary.plots <- function(meta_data, file_name = "summary", environment = FALSE, width = 12, height =8, ... ) {
#first Graph
data.summary <- function(x) { #function to calculate median + sd for violin plots
mu <- mean(x)
sigma1 <- mu-sd(x)
sigma2 <- mu+sd(x)
return(c(y=mu, ymin=sigma1, ymax=sigma2))
}
### 1. ###################### Boxplots(gender, age) ~ status
firstGraph <- ggplot(organ_metadata, aes(x = gender, y = age/365)) +
geom_boxplot(data = organ_metadata, aes(color = status)) +
Expand Down
5 changes: 4 additions & 1 deletion R/use.prop.test.R
Expand Up @@ -3,7 +3,10 @@
#' @param df_count A data frame, made by >count.column<
#' @param eval_first_column Boolean, should the first column be evaluated as well?
#' @examples
#' df <- data.frame(case_id = c(1,2,3,4,5,6), group = c("one","one","two","one","two","three"), primary_diagnosis = c("Squamous cell carcinoma, NOS", "Adenocarcinoma, NOS", "Adenocarcinoma with mixed subtypes", "Squamous cell carcinoma, NOS", "Squamous cell carcinoma, NOS", "Squamous cell carcinoma, NOS"))
#' df <- data.frame(case_id = c(1,2,3,4,5,6),
#' group = c("one","one","two","one","two","three"),
#' primary_diagnosis = c("Squamous cell carcinoma, NOS", "Adenocarcinoma, NOS", "Adenocarcinoma with mixed subtypes",
#' "Squamous cell carcinoma, NOS", "Squamous cell carcinoma, NOS", "Squamous cell carcinoma, NOS"))
#' diagnosis_counts <- count.column(df, factor_one = "group", factor_two = "primary_diagnosis")
#' pValues <- use.prop.test(diagnosis_counts, FALSE)
#' @return Returns a vector of p.values obtained by the prop.test
Expand Down
File renamed without changes.
15 changes: 13 additions & 2 deletions example/statistical.test.R
Expand Up @@ -12,6 +12,17 @@ x1 <- pairwise.wilcox.test(lungMetaExpression[[x[1]]]$expression, g = lungMetaEx
x2 <- x1 %>% tibble::rownames_to_column('name') %>% filter_all(. , any_vars(. < 0.05)) %>% tibble::column_to_rownames('name') #filter and keep rownames
x3 <- data.frame(t(x2)) %>% tibble::rownames_to_column('name') %>% filter_all(., any_vars(. < 0.05)) %>% tibble::column_to_rownames('name') #transpose to filter out rows without significant values, cant filter out colums that easy

wilcox_test(Value ~ factor(Group), data=data[data$Group==1|data$Group==2,], distribution="exact")
wilcox_test(Value ~ factor(Group), data=data[data$Group==1|data$Group==2,])
xWil <- wilcox.test(lungMetaExpression[[x[1]]]$expression ~ lungMetaExpression[[x[1]]]$primary_diagnosis == c("Adenocarcinoma, NOS" , "Squamous cell carninoma, NOS"))
#for every row: do wilcox test if p.value is <0.05 and not the same name ... furthermore try coin::wilcox_test

#for every row: do wilcox test if p.value is <0.05 and not the same name
rownames(x3)

#what if i subset expression values byy diagnosis factor
primaryDSpread <- lungMetaExpression$AL671277.1 %>% select(. , c(case_id, primary_diagnosis, expression)) %>% tidyr::spread(., primary_diagnosis, expression)
wilcox.test(primaryD$`Papillary adenocarcinoma, NOS`, primaryD$`Papillary adenocarcinoma, NOS`)
primaryD <- lungMetaExpression$AL671277.1 %>% select(. , primary_diagnosis, expression)
firstTest <- filter(primaryD, primary_diagnosis %in% c("Adenocarcinoma, NOS", "Squamous cell carcinoma, NOS")) #filter if they are named like this

coin::wilcox_test(formula = expression ~ primary_diagnosis, data = firstTest)
# FUNKTIONIERT
24 changes: 24 additions & 0 deletions man/add.expression.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/add.stage.simple.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/count.column.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions man/counts.per.group.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/drop.unused.levels.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/filter.columns.as.na.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/make.kruskal.frame.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions man/make.nested.metadata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/make.overview.metadata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/make.prop.frame.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c5d03d2

Please sign in to comment.