@@ -90,35 +90,46 @@ process SPACEMARKERS_MQC {
9090
9191 #[['']] notation needed to allow nextflow var susbtitution
9292
93+ #init all report variables
94+ n_pairs_total <- NA
95+ n_pairs_interact <- NA
96+ min_spacemarker_metric <- NA
97+ max_spacemarker_metric <- NA
98+ min_genes <- NA
99+ max_genes <- NA
100+ avg_hotspot_area <- NA
101+
93102 sm <- readRDS("$spaceMarkers ")
94103 smi <- sm[which(sapply(sm, function(x) length(x[['interacting_genes']]))>0)]
95104
96105 #interacting patterns stats
97106 n_pairs_total <- length(sm)
98107 n_pairs_interact <- length(smi)
99108
100- #spacemarker metric
101- max_spacemarker_metric <- max(sapply(smi, function(x) {
102- max(x[['interacting_genes']][[1]][['SpaceMarkersMetric']])
103- }))
104- min_spacemarker_metric <- min(sapply(smi, function(x) {
105- min(x[['interacting_genes']][[1]][['SpaceMarkersMetric']])
106- }))
107-
108- #average number of genes in each pair
109- min_genes <- min(sapply(smi, function(x) {
110- nrow(x[['interacting_genes']][[1]])
111- }))
112-
113- #average number of genes in each pair
114- max_genes <- max(sapply(smi, function(x) {
115- nrow(x[['interacting_genes']][[1]])
116- }))
117-
118- #average percent overlap across interacting patterns
119- avg_hotspot_area <- mean(sapply(smi, function(x) {
120- sum(!is.na(x[['hotspots']]))/length(x[['hotspots']][,1])
121- }))
109+ if(n_pairs_interact >0 ) {
110+ #spacemarker metric
111+ max_spacemarker_metric <- max(sapply(smi, function(x) {
112+ max(x[['interacting_genes']][[1]][['SpaceMarkersMetric']])
113+ }))
114+ min_spacemarker_metric <- min(sapply(smi, function(x) {
115+ min(x[['interacting_genes']][[1]][['SpaceMarkersMetric']])
116+ }))
117+
118+ #average number of genes in each pair
119+ min_genes <- min(sapply(smi, function(x) {
120+ nrow(x[['interacting_genes']][[1]])
121+ }))
122+
123+ #average number of genes in each pair
124+ max_genes <- max(sapply(smi, function(x) {
125+ nrow(x[['interacting_genes']][[1]])
126+ }))
127+
128+ #average percent overlap across interacting patterns
129+ avg_hotspot_area <- mean(sapply(smi, function(x) {
130+ sum(!is.na(x[['hotspots']]))/length(x[['hotspots']][,1])
131+ }))
132+ }
122133
123134 #report
124135 report_data <- list(
0 commit comments