@@ -87,6 +87,46 @@ create_alldetected <- function(res, counts_data) {
87
87
return (as.data.frame(joined_data ))
88
88
}
89
89
90
+ # ######################################################################################
91
+ # # Added but not used
92
+ prepGroup <- function (conds = NULL , cols = NULL , metadata = NULL , covariates = NULL ) {
93
+ if (is.null(conds ) || is.null(cols )) return (NULL )
94
+ coldata <- data.frame (cbind(cols , conds ))
95
+ coldata $ conds <- factor (coldata $ conds )
96
+ colnames_coldata <- c(" libname" , " group" )
97
+ if (! is.null(covariates )){
98
+ if (covariates != " NoCovariate" ){
99
+ sample_column_ind <- which(apply(metadata , 2 , function (x ) sum(x %in% cols ) == length(cols )))
100
+ sample_column <- colnames(metadata )[sample_column_ind ]
101
+ covariates <- metadata [match(cols ,metadata [,sample_column ]), covariates , drop = FALSE ]
102
+ for (i in 1 : ncol(covariates )){
103
+ cur_covariate <- covariates [,i ]
104
+ cur_covariate <- factor (cur_covariate )
105
+ coldata <- data.frame (cbind(coldata , cur_covariate ))
106
+ colnames_coldata <- c(colnames_coldata , paste0(" covariate" ,i ))
107
+ }
108
+ }
109
+ }
110
+ colnames(coldata ) <- colnames_coldata
111
+ coldata
112
+ }
113
+
114
+ mrn_normalize <- function (df ) {
115
+
116
+ columns <- colnames(df )
117
+ conds <- columns
118
+ coldata <- prepGroup(conds , columns )
119
+ df [, columns ] <- apply(df [, columns ], 2 ,
120
+ function (x ) as.integer(x ))
121
+ dds <- DESeqDataSetFromMatrix(countData = as.matrix(df ),
122
+ colData = coldata , design = ~ group )
123
+ dds <- estimateSizeFactors(dds )
124
+ norm <- counts(dds , normalized = TRUE )
125
+ norm_df <- as.data.frame(norm )
126
+ return (norm_df )
127
+ }
128
+ # ######################################################################################
129
+
90
130
filter_and_save_csv <- function (alldetected , foldChange_cutoff , padj_cutoff , direction_change , out_directory_path ) {
91
131
92
132
# Filter rows based on the specified conditions
0 commit comments