R/corSamples.R

Defines functions corSamples

Documented in corSamples

#' Correlation of samples based on the panel of whole genome
#'
#' use the corSamples() fuction to initiate the correlation among samples
#' @import pheatmap FactoMineR factoextra
#' @param dataPath the direction of download Data
#' @export
corSamples<-function(dataPath){
setwd(dataPath)
load(file =".//output//step03.RData")
message("在所有样本间,进行基因表达相关性分析...",appendLF =F)

pdf(file = ".//output//step04_correlation_matrix.pdf",
    width =10,height = ncol(x_reduce)/12)
x_d<-x_reduce[rowSums(x_reduce>100)>ncol(x_reduce)/2,]
pheatmap::pheatmap(cor(log2(x_d+1),method = 'spearman'),
         col = colorRampPalette(c('green','white','red'))(100),cex=0.8,
         cellheight =5,treeheight_row = 30,show_colnames = F,cluster_cols = T,
         clustering_distance_rows = 'euclidean',scale = 'row')
dev.off()

pdf(file = ".//output//step04_PCA.pdf",
    width =10)
res.pca=FactoMineR::PCA(t(log2(x_reduce+1)),graph = F)
groups=sample_info$group
p=factoextra::fviz_pca_ind(
  res.pca,
  geom.ind="point",
  col.ind=groups,
  palette=c('#00AFBB','#E7B800'),
  addEllipses=T,
  legend.title="Groups",
  title="PCA of all Genes"
)
print(p)
dev.off()

message("Completed!")
}
dming1024/TCGApackages0226 documentation built on April 9, 2021, 7:48 a.m.