Skip to content

Instantly share code, notes, and snippets.

View maromato's full-sized avatar

Toshi maromato

View GitHub Profile
#import data
x <- read.table(file="DNAmet.txt",header=T,sep="\t") 
head(x)
# a b c d e
#1 PYROXD2 HPSE2 LOXL4 ABCC2 KAZALD1
#2 ENTPD7 ENTPD7 HPSE2 SH3PXD2A BTRC
#3 BLOC1S2 SCD ENTPD7 VWA2 FBXW4
#4 FAM178A FGF8 ABCC2 ADARB2 NOLC1
#5 FBXW4 ABLIM1 SCD CHST15 ELOVL3
pc <- c(65,51,29,75,50,1,70,47,37,36,45,44,57,66,60,71,40,39,34,21,27,17,43,19,49,88,58,55,30,18,64,74,72,63,26,22,28,52,35,23,68,41,62,24)#define the columns that you are interested in
t1 <- y[obj,pc]#making group1
t2 <- y[obj,-pc]#making group2
t <- cbind(t1,t2)
#define the comparison
c <- c(rep(1,44),rep(0,52))
#https://www1.doshisha.ac.jp/~mjin/R/36/36.htmlが参考になる。
#ID, OS, Status, DrugからなるTableを作る!
#ID= Patient Number,OS =length of time, Status =Death or Not, Drug=Control or test
library(survival)
#ファイルの読み込み
t <- read.table(file="FILE NAME.txt",header=T,sep="t",row.names=1)
#分析
#clustering
library(pheatmap)
x <- read.table("summary_est_mod.txt",header=T,sep="\t")
head(x)
y <- cor(x[,3:ncol(x)])
pheatmap(y)
#making a data file for analusis
z <- x[,3:ncol(x)]
@maromato
maromato / listoftable.r
Created February 14, 2016 05:07
Input multiple files from the folder into one data table
#making a list of the files in the folder "est"
estDataFiles <- list.files("est", pattern = "\\.txt$", full.names=TRUE)
estDataFiles
#inpu the files
listoftables <- lapply(estDataFiles, read.table, header=T, sep="\t")
names(listoftables) <- estDataFiles
#confirmation
head(listoftables[[1]])
#Initially, you need to normalize raw microarray data and make a spread sheet for gene expression as shown elsewhere.
#input spread sheet for microarray data
x = read.table("XXXX.txt",header=T,sep="\t")
x2 = x[,2:ncol(x)]
x2 = as.matrix (x2)