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 34 35 36 37 38 39 40
| f_TCGA_gleason_grade <- function(primary_gleason_grade, secondary_gleason_grade){ primary_gleason_grade <- as.numeric(unlist(data.frame(strsplit(primary_gleason_grade, ' '))[2,])) secondary_gleason_grade <- as.numeric(unlist(data.frame(strsplit(secondary_gleason_grade, ' '))[2,])) primary_gleason_grade + secondary_gleason_grade } f_rank_transformation_o <- function(lo){ lo <- unlist(lo) idx <- order(lo, decreasing = F) idm <- as.data.frame(table(lo)) idm <- idm[idm$Freq>1, ] idm <- idm[[1]] for(i in idm){ ii <- (lo == i) idx[ii] <- mean(idx[ii]) } names(idx) <- names(lo) idx } f_SCE_VlnBoxPlot_gD <- function(featureN, assayN='TPM', rank_trans=F, rmZero=NULL, log_trans=T, ...){ sceList <- list(...) df <- data.frame() for(name in names(sceList)){ sce <- sceList[[name]] idx <- rowRanges(sce)$external_gene_name == featureN tmp <- assay(sce[idx, ], assayN) tmp <- data.frame(groupN=name, value=tmp[1,]) df <- rbind(df, tmp) } if(log_trans){ df$value <- log1p(df$value) } if(rank_trans){ df$value <- f_rank_transformation_o(df$value) df }else{ if(!is.null(rmZero)){ df[df$value>rmZero, ] }else{df} } }
|