1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| require(tidyverse) f_cDB_order_sequence <- function(lc_df){ da <- data.frame() df <- subset(lc_df, receptor_a == 'True' & receptor_b == 'False' receptor_a == 'False' & receptor_b == 'True') for(i in 1:length(df$gene_a)){ sub_data <- df[i, ] if(sub_data$receptor_b=='False'){ if(sub_data$receptor_a=='True'){ old_names <- colnames(sub_data) my_list <- strsplit(old_names[-c(1:11)], split="\\") my_character <- paste(sapply(my_list, '[[', 2L), sapply(my_list, '[[', 1L), sep='') new_names <- c(names(sub_data)[1:4], 'gene_b', 'gene_a', 'secreted', 'receptor_b', 'receptor_a', "annotation_strategy", "is_integrin", my_character) sub_data = dplyr::select(sub_data, new_names) names(sub_data) <- old_names da = rbind(da, sub_data) } }else{ da = rbind(da, sub_data) } } return(da) } f_cDB_mergePandM <- function(means_order, pvals_order){ means_sub <- means_order[, c('interacting_pair', colnames(means_order)[-c(1:11)])] pvals_sub <- pvals_order[, c('interacting_pair', colnames(means_order)[-c(1:11)])] means_gather <- tidyr::gather(means_sub, celltype, mean_expression, names(means_sub)[-1]) pvals_gather <- tidyr::gather(pvals_sub, celltype, pval, names(pvals_sub)[-1]) mean_pval <- dplyr::left_join(means_gather, pvals_gather, by = c('interacting_pair', 'celltype')) mean_pval }
|