Browse code

Debugging check problems, basically because of the SummarizedExperiment, and bumping version

Marta R. Hidalgo authored on 17/04/2019 17:47:04
Showing5 changed files

... ...
@@ -1,6 +1,6 @@
1 1
 Package: hipathia
2 2
 Title: HiPathia: High-throughput Pathway Analysis
3
-Version: 1.99.4
3
+Version: 1.99.5
4 4
 Authors@R: c(person("Marta R.", "Hidalgo", email = "marta.hidalgo@outlook.es", role = c("aut", "cre")),
5 5
 	     person("José", "Carbonell-Caballero", role = c("ctb")),
6 6
 	     person("Francisco", "Salavert", role = c("ctb")),
... ...
@@ -378,8 +378,8 @@ compute_node_signal <- function(actnode, node_val, node_signal, subgraph,
378 378
         }
379 379
 
380 380
         # If signal too low, signal do not propagate
381
-        if(sum(nas) == 0 && signal < response_tol)
382
-            signal <- rep(0, length(node_val))
381
+        if(sum(nas) == 0 && any(signal < response_tol))
382
+            signal[signal < response_tol] <- 0
383 383
 
384 384
     }
385 385
 
... ...
@@ -587,8 +587,13 @@ get_pathways_summary <- function(comp, metaginfo, conf = 0.05){
587 587
 #'
588 588
 top_pathways <- function(comp){
589 589
     
590
-    path_names <- as.character(comp$path_names)
591
-    comp$pathways <- sapply(strsplit(path_names, split = ":"), "[[", 1)
590
+    if("name" %in% colnames(comp)){
591
+        path_names <- as.character(comp$name)
592
+        comp$pathways <- sapply(strsplit(path_names, split = ":"), "[[", 1)
593
+    }else{
594
+        path_names <- rownames(comp)
595
+        comp$pathways <- sapply(strsplit(path_names, split = "-"), "[[", 2)
596
+    }
592 597
     pathways <- unique(comp$pathways)
593 598
     
594 599
     tests <- do.call(rbind, lapply(pathways, function(path) {
... ...
@@ -859,10 +859,11 @@ paths_to_go_ancestor <- function(pathways, comp_paths, comp_go, pval = 0.05){
859 859
 #' by dividing by the value obtained from running the method with a basal
860 860
 #' value of 0.5 at each node.
861 861
 #'
862
-#' @param path_vals Matrix of the pathway values
862
+#' @param path_vals SummarizedExperiment or matrix of the pathway values
863 863
 #' @param metaginfo Pathways object
864 864
 #'
865
-#' @return Matrix of normalized pathway values
865
+#' @return SummarizedExperiment or matrix of normalized pathway values, 
866
+#' depending on the class of \code{path_vals}.
866 867
 #'
867 868
 #' @examples
868 869
 #' data(path_vals)
... ...
@@ -876,17 +877,24 @@ normalize_paths <- function(path_vals, metaginfo){
876 877
     decomposed <- is_decomposed_matrix(path_vals)
877 878
     if(decomposed == TRUE){
878 879
         norm_factors <- metaginfo$path.norm[rownames(path_vals)]
879
-        path_norm <- normalize_data(path_vals/(norm_factors*0.99+0.01),
880
-                                    by_quantiles = FALSE,
881
-                                    by_gene = FALSE,
882
-                                    percentil = FALSE)
883 880
     }else{
884 881
         norm_factors <- metaginfo$eff.norm[rownames(path_vals)]
885
-        path_norm <- normalize_data(path_vals/(norm_factors*0.99+0.01),
886
-                                    by_quantiles = FALSE,
887
-                                    by_gene = FALSE,
888
-                                    percentil = FALSE)
889 882
     }
883
+    if(is(path_vals, "SummarizedExperiment")){
884
+        coldata <- colData(path_vals)
885
+        path_vals <- assay(path_vals, "paths")
886
+        se_flag <- TRUE
887
+    }else{
888
+        se_flag <- FALSE
889
+    }
890
+    path_norm <- normalize_data(path_vals/(norm_factors*0.99+0.01),
891
+                                by_quantiles = FALSE,
892
+                                by_gene = FALSE,
893
+                                percentil = FALSE)
894
+    if(se_flag == TRUE)
895
+        path_norm <- SummarizedExperiment(list(path_norm = path_norm), 
896
+                                          colData = coldata)
897
+    
890 898
     return(path_norm)
891 899
 }
892 900
 
... ...
@@ -7,12 +7,13 @@
7 7
 normalize_paths(path_vals, metaginfo)
8 8
 }
9 9
 \arguments{
10
-\item{path_vals}{Matrix of the pathway values}
10
+\item{path_vals}{SummarizedExperiment or matrix of the pathway values}
11 11
 
12 12
 \item{metaginfo}{Pathways object}
13 13
 }
14 14
 \value{
15
-Matrix of normalized pathway values
15
+SummarizedExperiment or matrix of normalized pathway values, 
16
+depending on the class of \code{path_vals}.
16 17
 }
17 18
 \description{
18 19
 Due to the nature of the Hipathia method, the length of a pathway may