diff --git a/inst/shinyapp/modules/03_tcga/modules-pancan-comp-m2o.R b/inst/shinyapp/modules/03_tcga/modules-pancan-comp-m2o.R index 264a5003..fd9383df 100644 --- a/inst/shinyapp/modules/03_tcga/modules-pancan-comp-m2o.R +++ b/inst/shinyapp/modules/03_tcga/modules-pancan-comp-m2o.R @@ -229,7 +229,8 @@ server.modules_pancan_comp_m2o = function(input, output, session) { data = dplyr::inner_join(y_data, group_data) %>% dplyr::select(Sample, value, group, everything()) %>% na.omit() # 检查数据是否合理 - if(nrow(data)==0 | sd(data$value)==0 | length(unique(data$group))==1) return(c(NaN, NaN, NaN)) + if(nrow(data)==0 | sd(data$value)==0) return(c(NaN, NaN, NaN)) + if(length(unique(data$group))==1 | min(table(data$group))<3) return(c(NaN, NaN, NaN)) if(input$comp_method == "t.test"){ comp_obj = t.test(value ~ group, data) diff --git a/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2m.R b/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2m.R index b177b39b..a679c823 100644 --- a/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2m.R +++ b/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2m.R @@ -265,7 +265,7 @@ server.modules_pancan_comp_o2m = function(input, output, session) { merge_data_line() %>% dplyr::group_by(cancer, group) %>% dplyr::summarise(n1=n()) %>% - dplyr::filter(n1>=2) %>% # 每小组的样本数大于等于2 + dplyr::filter(n1>=3) %>% # 每小组的样本数大于等于3 dplyr::distinct(cancer, group) %>% dplyr::count(cancer,name = "n2") %>% dplyr::filter(n2==2) %>% dplyr::pull("cancer") # 每个肿瘤有两组 diff --git a/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2o.R b/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2o.R index cbce1555..7e4d8d31 100644 --- a/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2o.R +++ b/inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2o.R @@ -268,10 +268,10 @@ server.modules_pancan_comp_o2o = function(input, output, session) { shiny::validate( need(try(nrow(merge_data_box())>0), "Please inspect whether to set groups or download variable data in S2 or S3 step."), - ) - shiny::validate( need(try(length(unique(merge_data_box()$group))==2), - "No enough samples for comparing, please check your input."), + "No two groups for comparing, please check your input."), + need(try(min(table(merge_data_box()$group))>2), + "No enough samples (n≤3) for one group for comparing, please check your input."), ) merge_data_box = merge_data_box() diff --git a/inst/shinyapp/modules/03_tcga/modules-pancan-cor-m2o.R b/inst/shinyapp/modules/03_tcga/modules-pancan-cor-m2o.R index b9dc4108..14675715 100644 --- a/inst/shinyapp/modules/03_tcga/modules-pancan-cor-m2o.R +++ b/inst/shinyapp/modules/03_tcga/modules-pancan-cor-m2o.R @@ -213,7 +213,7 @@ server.modules_pancan_cor_m2o = function(input, output, session) { xy_data = x_datas %>% dplyr::filter(x_id == L3_x) %>% dplyr::inner_join(y_data) %>% as.data.frame() - if(nrow(na.omit(xy_data))==0){return(c(NaN, NaN))} + if(nrow(na.omit(xy_data))<3){return(c(NaN, NaN))} cor_obj = cor.test(xy_data[,"x_value"],xy_data[,"y_value"], method = input$cor_method) incProgress(1 / length(L3s_x()), detail = paste0("(Finished ",i,"/",length(L3s_x()),")")) diff --git a/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2m.R b/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2m.R index e68ff441..7b98808c 100644 --- a/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2m.R +++ b/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2m.R @@ -253,9 +253,16 @@ server.modules_pancan_cor_o2m = function(input, output, session) { colnames(x_axis_data)[c(1:3,5)] = paste0("x_",colnames(x_axis_data)[c(1:3,5)]) y_axis_data = y_axis_data() colnames(y_axis_data)[c(1:3,5)] = paste0("y_",colnames(y_axis_data)[c(1:3,5)]) - data = dplyr::inner_join(x_axis_data, y_axis_data) %>% dplyr::select(cancer, Sample, everything()) + + data <- data %>% + dplyr::filter(cancer %in% ( + data %>% + dplyr::count(cancer) %>% + dplyr::filter(n > 2) %>% + dplyr::pull(cancer) + )) # print(head(data)) data }) diff --git a/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2o.R b/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2o.R index 55ef32aa..8d7bdb24 100644 --- a/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2o.R +++ b/inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2o.R @@ -269,6 +269,8 @@ server.modules_pancan_cor_o2o = function(input, output, session) { shiny::validate( need(try(nrow(merge_data_sct())>0), "Please inspect whether to get valid data in Step2."), + need(try(nrow(merge_data_sct())>2), + "Please adjust to ensure that enough samples (n≥3) are included for analysis.") ) p = plot_cor_o2o( data = merge_data_sct(), cor_method = input$cor_method, diff --git a/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R b/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R index 70abd629..75a364e8 100644 --- a/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R +++ b/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R @@ -264,51 +264,50 @@ download_feat_Server = function(input, output, session, database = "toil",#id_op x_data$cancer = clinical_phe[,2,drop=T][match(x_data$Sample, clinical_phe$Sample)] x_data = x_data[,c("id","level1","level2","Sample","value","cancer")] %>% dplyr::arrange(cancer,Sample) - # shinyjs::enable("query_data") + shinyjs::enable("query_data") x_data }) w <- waiter::Waiter$new(id = ns("x_axis_data_table"), html = waiter::spin_hexdots(), color = "black") - observeEvent(input$query_data,{ - - w$show() - output$x_axis_data_table = renderUI({ - if(table.ui){ - output$x_tmp_table = renderDataTable({ - shinyjs::enable("query_data") - - shiny::validate( - need(try(nrow(download_data())>0), - "No sample data available. Please inspect operations in Preset step."), - ) - if(check_numeric){ + # observeEvent(input$query_data,{ + observe({ + if (input$query_data>0) { + w$show() + output$x_axis_data_table = renderUI({ + if(table.ui){ + output$x_tmp_table = renderDataTable({ + # shinyjs::enable("query_data") shiny::validate( - need(try(class(download_data()$value)!="character"), - "Please select a numeric variable."), - ) - } - x_axis_data_ = download_data()[,c("Sample","value","cancer")] - - if(class(x_axis_data_[,"value"])=="numeric"){ - x_axis_data_[,"value"] = round(x_axis_data_[,"value"], digits = 3) - } - datatable(x_axis_data_, - options = list(pageLength = 3, - columnDefs = list(list(className = 'dt-center', targets="_all"))) - ) - }) - dataTableOutput(ns("x_tmp_table")) - } else { - output$x_tmp_table = renderPrint({ - # ids_num = nrow() - cat(paste0("Tip: identifier values of ", nrow(download_data()), " samples are prepared.")) - }) - verbatimTextOutput(ns("x_tmp_table")) - } + need(try(nrow(download_data())>0), + "No sample data available. Please inspect operations in Preset step."), + ) + if(check_numeric){ + shiny::validate( + need(try(class(download_data()$value)!="character"), + "Please select a numeric variable."), + ) + } + x_axis_data_ = download_data()[,c("Sample","value","cancer")] - }) - + if(class(x_axis_data_[,"value"])=="numeric"){ + x_axis_data_[,"value"] = round(x_axis_data_[,"value"], digits = 3) + } + datatable(x_axis_data_, + options = list(pageLength = 3, + columnDefs = list(list(className = 'dt-center', targets="_all"))) + ) + }) + dataTableOutput(ns("x_tmp_table")) + } else { + output$x_tmp_table = renderPrint({ + # ids_num = nrow() + cat(paste0("Tip: identifier values of ", nrow(download_data()), " samples are prepared.")) + }) + verbatimTextOutput(ns("x_tmp_table")) + } + }) + } }) # observeEvent(input$query_data,{ diff --git a/inst/shinyapp/utils_appdata.R b/inst/shinyapp/utils_appdata.R index 2961b5bd..8ab2df9b 100644 --- a/inst/shinyapp/utils_appdata.R +++ b/inst/shinyapp/utils_appdata.R @@ -92,7 +92,7 @@ tcga_id_option = list( ), "TIMER" = list( "all" = tcga_id.list[["TIMER"]], - "default" = "Monocyte" + "default" = "Macrophage" ), "XCELL" = list( "all" = tcga_id.list[["XCELL"]], diff --git a/inst/shinyapp/utils_plot.R b/inst/shinyapp/utils_plot.R index 256249a8..8b97daf4 100644 --- a/inst/shinyapp/utils_plot.R +++ b/inst/shinyapp/utils_plot.R @@ -97,7 +97,12 @@ plot_comb_o2m = function(data1, data2, x_name, title_name, p1 = ggplot(data1_sub) + stat_summary(aes(x=cancer, y=value, color=group), - position=position_dodge(width=0.5)) + + # colour = "gray", + position=position_dodge(width=0.5)) + + geom_jitter(aes(x=cancer, y=value, color=group), + position=position_dodge(width=0.5), size = 1, + # colour = "gray", + alpha = 0.4) + xlab("") + ylab(x_name) + ggtitle(label = title_name) + #转置 scale_color_manual(values = c(group_1_color_2, group_2_color_2)) + coord_flip() + custom_theme