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 41 42 43 44 45
| require(Biobase) f_rm_duplicated <- function(NameL, reverse=F){ tmp <- data.frame(table(NameL)) if(reverse){ tmp <- tmp$NameL[tmp$Freq > 1] }else{ tmp <- tmp$NameL[tmp$Freq == 1] } which(NameL %in% as.character(tmp)) } f_name_dedup <- function(lc_exp, rowN = 1){ if (rowN == 0){ res <- lc_exp rowNn <- rownames(lc_exp) }else{ res <- lc_exp[-rowN] rowNn <- lc_exp[[rowN]] } noDup <- f_rm_duplicated(rowNn) tmp <- rowNn[noDup] noDup <- res[noDup,] rownames(noDup) <- tmp Dup <- f_rm_duplicated(rowNn, T) rowNn <- rowNn[Dup] Dup <- res[Dup,] rownames(Dup) <- NULL lc_tmp = by(Dup, rowNn, function(x) rownames(x)[which.max(rowMeans(x))]) lc_probes = as.integer(lc_tmp) Dup = Dup[lc_probes,] rownames(Dup) <- rowNn[lc_probes] return(rbind(noDup,Dup)) } prad <- readRDS('~/work_st/zl_liu_new/Bulk/tcga/PRAD/prad_counts.rds') prad <- prad[,f_rm_duplicated(colnames(prad))] prad <- f_name_dedup(prad, 0) metadata <- data.frame(labelDescription=c('SampleID'), row.names=c('SampleID')) meta <- data.frame(SampleID = colnames(prad), row.names = colnames(prad)) phenoData <- new("AnnotatedDataFrame",data=meta,varMetadata=metadata, dimLabels = c('sampleNames','sampleColumns')) bulk.eset <- ExpressionSet(assayData=prad, phenoData=phenoData) bulk.eset saveRDS(bulk.eset, 'bulk.eset.rds')
|