################################################################################# ###Data Load and Overview######################################################## ################################################################################# getwd() #ÇöÀçÀÇ ÀÛ¾÷°ø°£ È®ÀÎÇϱâ setwd("C:/R_data/lecture10") #Á¦ 10°­ µ¥ÀÌÅÍ°¡ ÀÖ´Â °÷À¸·Î À̵¿ dir() ################################################################################# ################################################################################# ###°¢°¢ÀÇ ÆÄÀÏÀ» º¯¼ö·Î ºÒ·¯¿À±â### cli <- read.csv("JAMA_Clinical.csv", header=T, na.strings="null") mut <- read.delim("JAMA_Mutation.txt", header=T) met <- read.delim("JAMA_BRCA1_Methyl.txt",header=T) exp <- read.delim("JAMA_Expression.txt", header=T) ################################################################################## ################################################################################## ###µ¥ÀÌÅÍÀÇ ±¸Á¶¿Í Å©±â ÆľÇÇϱâ### ls() #loadingÇÑ µ¥ÀÌÅÍ È®ÀÎ head(cli) #first 1~6 row ¸¸ º¸±â str(cli) #±¸Á¶È®ÀÎ dim(cli) #dimension È®ÀÎ summary(cli) #basic statistics È®ÀÎ head(mut) head(met) head(exp) ################################################################################# ################################################################################# ####BRCA1/2 mutationÀ» °¡Áø sample ÃßÃâÇϱâ### brca1.mut <- unique(as.character(mut[which(mut[,2] =="BRCA1" ),1])) #mut table¿¡¼­ gene À̸§ÀÌ brca1ÀÎ sample ÃßÃâ brca2.mut <- unique(as.character(mut[which(mut[,2] =="BRCA2" ),1])) brca1.mut #Ãâ·ÂÇؼ­ È®ÀÎ brca2.mut ################################################################################# ################################################################################# ###BRCA1 expression level ÃßÃâÇϱâ### brca1.exp <- as.numeric(exp[which(exp[,1]=="BRCA1"),-1]) # BRCA1 gene¿¡ ´ëÇÑ expression level ÃßÃâ head(brca1.exp) ###BRCA1 expression°ú »ó°ü°ü°è°¡ ³ôÀº methylation probe ÃßÃâÇϱâ### apply(met[,-1], 1, function(x)cor(x, brca1.exp)) exp.cor <- apply(met[,-1], 1, function(x)cor(x, brca1.exp)) #apply ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© BRCA1 expression level°ú °¢°¢ÀÇ methylation probeÀÇ beta value°£ÀÇ pearson correlation coefficient¸¦ ±¸ÇÑ´Ù. TestMatrix <- met[which(abs(exp.cor) > 0.3),-1] #BRCA1 expressionÀÌ ´Þ¶óÁø methylation prove¸¦ ã´Â´Ù. heatmap(as.matrix(TestMatrix)) #methylation patternÀÌ ´Ù¸¥ »ùÇÃÀ» ã±â À§ÇØheatmapÀ» ±×¸°´Ù. ############################################################################### ############################################################################### ###cluster dendrogramÀ» ÀÌ¿ëÇØ BRCA1 methylation ÀÌ ´Þ¶óÁø »ùÇà ã±â### AA<- hclust(dist(t(TestMatrix))) plot(AA) M<-identify(AA) #R graphic â¿¡ ³ªÅ¸³­ dendrogram¿¡¼­ °¡Àå ¿ÞÂÊ¿¡ Â÷À̳ª´Â »ùÇõéÀ» ¼±ÅÃ(¿ÞÂÊŬ¸¯)ÇÑ ÈÄ stop(¿À¸¥ÂÊŬ¸¯Çؼ­ ³ªÅ¸³ª´Â stop¼±ÅÃ) M #È®ÀÎ brca1.met<- names(met[,as.numeric(M[[1]])]) #BRCA1 methylation ÀÌ ´Ù¸¥ sampleÀ» º¯¼ö¿¡ ÇÒ´ç brca1.met #È®ÀÎ ############################################################################### ############################################################################### ###survival analysis Çϱâ### type <- c(rep('wild', 317)) #¸ÕÀú Àüü typeÀÌ wild ÀÎ º¯¼ö¸¦ ¸¸µç´Ù. names(type)<-cli[,1] #column ¸íÀ» ȯÀÚ id ·Î ¹Ù²ãÁØ´Ù. brca1.met<-gsub(".","-",brca1.met, fixed=T) #»ùÇÃÀÇ À̸§ Ç¥±â°¡ ¼­·Î ´Ù¸£¹Ç·Î À̸¦ ¹Ù²ãÁØ´Ù. brca1.mut #ºÐ¼®ÇÒ Å×À̺í È®ÀÎ brca2.mut brca1.met #±³Àç ¿ÀŸ type[brca1.mut] #»ùÇú° typeÀ» ¹Ù²ãÁÜ type[brca1.met] = 'brca1.met' type[brca1.mut] = 'brca1.mut' type[brca2.mut] = 'brca2.mut' library(survival) #survival ºÐ¼®À» À§ÇÑ ÇÔ¼ö¸¦ ºÒ·¯¿Â´Ù. out <- survfit(Surv(cli$days_to_last_followup) ~ type) color <- c("green","blue", "red","black") #4°³ ±ºÀ» ³ªÅ¸³¾ »ö±òÀ» Á¤ÇصдÙ. plot(out, col=color , main="Association of BRCA1/2 Mutations with Survival", xlab="Time,days", ylab="Proportion") #plot legend(4200, 0.9, c("BRCA1 mutation","BRCA1 methylation","BRCA2 mutation","wild"), col=color, lty=1, lwd=3) ###############################################################################