recount.Rmd 14.7 KB
Newer Older
Venkat Malladi's avatar
Venkat Malladi committed
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
# Recount TCGA and GTEX data sets

source('http://bioconductor.org/biocLite.R')
biocLite('recount')
biocLite("org.Hs.eg.db")

install.packages("Rmisc")
library('recount')
library('org.Hs.eg.db')
library(ggplot2)
library(stringr)
library(reshape2)
library(Rmisc)



#GTEX breast
load(file.path('recount/rse_gene_breast_GTEX.Rdata'))
rpkm_breast_gtex  <- getRPKM(scale_counts(rse_gene, by = 'mapped_reads'))


#TCGA breast
load(file.path('recount/rse_gene_TCGA.Rdata'))
#rse_tcga <- scale_counts(rse_gene)
#rpkm_tcga  <- getRPKM(scale_counts(rse_gene))
load(file.path('recount/rse_TCGA.Rdata'))
load(file.path('recount/rpkm_TCGA.Rdata'))

#TCGAbiolinksGUI Metadata
load('recount/TCGA-BRCA_clinical.rda')
load('recount/TCGA-BRCA_Gene_expression_Gene_expression_quantification_hg19.rda')


# Get only set of Genes
# SNGH3 ENSG00000242125.3
# SNGH4 ENSG00000281398.2


host_gtex <-data.frame(t(rpkm_breast_gtex[which(rownames(rpkm_breast_gtex) %in% c("ENSG00000242125.3","ENSG00000281398.2")),]))
colnames(host_gtex) <- c('SNGH3','SNGH4')



phen <- data.frame(rse_tcga$bigwig_file,rse_tcga$gdc_cases.project.primary_site, rse_tcga$cgc_sample_sample_type,rse_tcga$cgc_case_pathologic_stage, rse_tcga$xml_breast_carcinoma_estrogen_receptor_status, rse_tcga$xml_breast_carcinoma_progesterone_receptor_status,rse_tcga$gdc_cases.samples.submitter_id)
colnames(phen) <- c('Experiment', 'Site', 'Type', 'Stage', 'ER', 'PR','sample')
phen$Experiment <- gsub(".bw", "", phen$Experiment)
rownames(phen) <- phen$Experiment

host_tcga <- data.frame(t(rpkm_tcga[which(rownames(rpkm_tcga)  %in% c("ENSG00000242125.3","ENSG00000281398.2")),]))
colnames(host_tcga) <-  c('SNGH3','SNGH4')
host_tcga['Experiment'] <- rownames(host_tcga)
tt <- merge(phen,host_tcga)

host_tcga_breast <- tt[which(tt$Site %in% c('Breast')),]
tcga_meta_data <- colData(data)[c('sample','subtype_PAM50.mRNA')]
colnames(tcga_meta_data) <- c('sample', 'PAM')
host_tcga_breast_pam <- merge(host_tcga_breast, tcga_meta_data, by.x=c("sample"), by.y=c("sample"))

# Merge TCGA and GTeX
df_pam <- data.frame(host_tcga_breast_pam[,c('SNGH3','SNGH4','PAM','Type')])
host_gtex$PAM <- "GTEX"
host_gtex$Type <- "GTEX"
df_tcag_gtex <- rbind(df_pam,host_gtex)

# Update Metaststic to Primary Tumor Type
df_tcag_gtex$Type[df_tcag_gtex$Type == 'Metastatic'] <- 'Primary Tumor'
df_tcag_gtex_pam <- df_tcag_gtex[complete.cases(df_tcag_gtex[ , 3]),]
df_tcag_gtex_type <- df_tcag_gtex[complete.cases(df_tcag_gtex[ , 4]),]

# Plot based SNGH3
df_SNGH3_type <- data.frame(df_tcag_gtex_type[,c('SNGH3','Type')])

p <- ggplot(aes(y = log2(SNGH3+1), x = Type, fill= Type ), data = df_SNGH3_type,) +  stat_boxplot(geom ='errorbar',lwd=1.5) + geom_boxplot(lwd=1.5,outlier.size = 1.5,outlier.shape = NA)  + labs(y="log2(RPKM+1)",x="Type", title="SNGH3") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(0,6))
jpeg('figures/SNGH3_breast_correlation_type.jpg')
p
dev.off()

df_SNGH3_pam <- data.frame(df_tcag_gtex_pam[,c('SNGH3','PAM')])

p <- ggplot(aes(y = log2(SNGH3+1), x = PAM, fill= PAM ), data = df_SNGH3_pam,) +  stat_boxplot(geom ='errorbar',lwd=1.5) +  geom_boxplot(lwd=1.5,outlier.size = 1.5,outlier.shape = NA)  + labs(y="log2(RPKM+1)",x="Type",title="SNGH3") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(0,6))
jpeg('figures/SNGH3_breast_correlation_pam.jpg')
p
dev.off()

# Plot based SNGH4
df_SNGH4_type <- data.frame(df_tcag_gtex_type[,c('SNGH4','Type')])

p <- ggplot(aes(y = log2(SNGH4+1), x = Type, fill= Type ), data = df_SNGH4_type,) +  stat_boxplot(geom ='errorbar',lwd=1.5) + geom_boxplot(lwd=1.5,outlier.size = 1.5,outlier.shape = NA)  + labs(y="log2(RPKM+1)",x="Type", title="SNGH4") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(0,3))
jpeg('figures/SNGH4_breast_correlation_type.jpg')
p
dev.off()

df_SNGH4_pam <- data.frame(df_tcag_gtex_pam[,c('SNGH4','PAM')])

p <- ggplot(aes(y = log2(SNGH4+1), x = PAM, fill= PAM ), data = df_SNGH4_pam,) +  stat_boxplot(geom ='errorbar',lwd=1.5) +  geom_boxplot(lwd=1.5,outlier.size = 1.5,outlier.shape = NA)  + labs(y="log2(RPKM+1)",x="Type",title="SNGH4") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(0,3))
jpeg('figures/SNGH4_breast_correlation_pam.jpg')
p
dev.off()
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155

# Look at PARP1 and DDX21
#PARP1 ENSG00000143799.12
#DDX21 ENSG00000165732.12

pd_gtex <- data.frame(t(rpkm_breast_gtex[which(rownames(rpkm_breast_gtex) %in% c("ENSG00000143799.12","ENSG00000165732.12")),]))
colnames(pd_gtex) <- c('PARP1','DDX21')



phen <- data.frame(rse_tcga$bigwig_file,rse_tcga$gdc_cases.project.primary_site, rse_tcga$cgc_sample_sample_type,rse_tcga$cgc_case_pathologic_stage, rse_tcga$xml_breast_carcinoma_estrogen_receptor_status, rse_tcga$xml_breast_carcinoma_progesterone_receptor_status,rse_tcga$gdc_cases.samples.submitter_id)
colnames(phen) <- c('Experiment', 'Site', 'Type', 'Stage', 'ER', 'PR','sample')
phen$Experiment <- gsub(".bw", "", phen$Experiment)
rownames(phen) <- phen$Experiment

pd_tcga <- data.frame(t(rpkm_tcga[which(rownames(rpkm_tcga)  %in% c("ENSG00000143799.12","ENSG00000165732.12")),]))
colnames(pd_tcga) <-  c('PARP1','DDX21')
pd_tcga['Experiment'] <- rownames(pd_tcga)
tt <- merge(phen,pd_tcga)

pd_tcga_breast <- tt[which(tt$Site %in% c('Breast')),]
tcga_meta_data <- colData(data)[c('sample','subtype_PAM50.mRNA')]
colnames(tcga_meta_data) <- c('sample', 'PAM')
pd_tcga_breast_pam <- merge(pd_tcga_breast, tcga_meta_data, by.x=c("sample"), by.y=c("sample"))

# Merge TCGA and GTeX
df_pd_pam <- data.frame(pd_tcga_breast_pam[,c('PARP1','DDX21','PAM','Type')])
pd_gtex$PAM <- "GTEX"
pd_gtex$Type <- "GTEX"
df_pd_tcag_gtex <- rbind(df_pd_pam,pd_gtex)

# Update Metastatic to Primary Tumor Type
df_pd_tcag_gtex$Type[df_pd_tcag_gtex$Type == 'Metastatic'] <- 'Primary Tumor'
df_pd_tcag_gtex_pam <- df_pd_tcag_gtex[complete.cases(df_pd_tcag_gtex[ , 3]),]
df_pd_tcag_gtex_type <- df_pd_tcag_gtex[complete.cases(df_pd_tcag_gtex[ , 4]),]

# Seperate into PAM and type for different genes
df_pd_tcag_gtex_pam$PARP1 <- log2(df_pd_tcag_gtex_pam$PARP1)
df_pd_tcag_gtex_pam$DDX21 <- log2(df_pd_tcag_gtex_pam$DDX21)

## PARP1 and PAM
df_pd_PAM_tcag_gtex_summary <- summarySE(df_pd_tcag_gtex_pam, measurevar="PARP1", groupvars=c("PAM"))
p <- ggplot(df_pd_PAM_tcag_gtex_summary, aes(x = as.factor(PAM), fill= PAM)) +
  geom_boxplot(aes(
      lower = PARP1 - se,
      upper = PARP1 + se,
      middle = PARP1,
      ymin = PARP1 - 2*se,
      ymax = PARP1 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(df_pd_tcag_gtex_pam$PARP1), linetype = 2) + labs(y="RPKM",x="PAM") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(1.5,2.5))
jpeg('figures/PARP1_breast_correlation_PAM_boxplot.jpg')
p
dev.off()

parp1_pam.aov = aov(PARP1 ~ PAM,data=df_pd_tcag_gtex_pam)
summary(parp1_pam.aov)

Venkat Malladi's avatar
Venkat Malladi committed
156
## DDX21 and PAM
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
df_ddx21_PAM_tcag_gtex_summary <- summarySE(df_pd_tcag_gtex_pam, measurevar="DDX21", groupvars=c("PAM"))
p <- ggplot(df_ddx21_PAM_tcag_gtex_summary, aes(x = as.factor(PAM), fill= PAM)) +
  geom_boxplot(aes(
      lower = DDX21 - se,
      upper = DDX21 + se,
      middle = DDX21,
      ymin = DDX21 - 2*se,
      ymax = DDX21 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(df_pd_tcag_gtex_pam$DDX21), linetype = 2) + labs(y="RPKM",x="PAM") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(3,5))
jpeg('figures/DDX21_breast_correlation_PAM_boxplot.jpg')
p
dev.off()

ddx21_pam.aov = aov(DDX21 ~ PAM,data=df_pd_tcag_gtex_pam)
summary(ddx21_pam.aov)
Venkat Malladi's avatar
Venkat Malladi committed
172 173 174 175 176 177 178 179 180 181 182 183 184


# Merge TCGA and GTeX
df_ET_pam <- data.frame(pd_tcga_breast_pam[,c('PARP1','DDX21','ER','Type')])
pd_gtex$ER <- "GTEX"
pd_gtex$Type <- "GTEX"
df_et_tcag_gtex <- rbind(df_ET_pam,pd_gtex)

# Update Metastatic to Primary Tumor Type
df_et_tcag_gtex$Type[df_et_tcag_gtex$Type == 'Metastatic'] <- 'Primary Tumor'
df_et_tcag_gtex_er <- df_et_tcag_gtex[complete.cases(df_et_tcag_gtex[ , 3]),]
df_et_tcag_gtex_er_type <- df_et_tcag_gtex_er[complete.cases(df_et_tcag_gtex_er[ , 4]),]
df_et_tcag_gtex_er_type_com <- df_et_tcag_gtex_er_type[which(df_et_tcag_gtex_er_type$ER %in% c('Negative','Positive','Normal')),]
185
df_et_tcag_gtex_type <- df_et_tcag_gtex[complete.cases(df_et_tcag_gtex[ , 4]),]
Venkat Malladi's avatar
Venkat Malladi committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225

# Seperate into PAM and type for different genes
df_et_tcag_gtex_er_type_com$PARP1 <- log2(df_et_tcag_gtex_er_type_com$PARP1)
df_et_tcag_gtex_er_type_com$DDX21 <- log2(df_et_tcag_gtex_er_type_com$DDX21)

df_et_tcag_gtex_er_type$ET <- paste(df_et_tcag_gtex_er_type$ER, df_et_tcag_gtex_er_type$Type, sep="")

## PARP1 and ER and Type
df_et_tcag_gtex_er_type_summary <- summarySE(df_et_tcag_gtex_er_type_com, measurevar="PARP1", groupvars=c("ER",'Type'))
p <- ggplot(df_et_tcag_gtex_er_type_summary, aes(x = as.factor(ER), fill= Type)) +
  geom_boxplot(aes(
      lower = PARP1 - se,
      upper = PARP1 + se,
      middle = PARP1,
      ymin = PARP1 - 2*se,
      ymax = PARP1 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(df_et_tcag_gtex_er_type_com$PARP1), linetype = 2) + labs(y="RPKM",x="PAM") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(3,5.5))
jpeg('figures/PARP1_breast_correlation_ER_TYPE_boxplot.jpg')
p
dev.off()

parp1_et.aov = aov(PARP1 ~ ER + Type ,data=df_et_tcag_gtex_er_type_summary)
summary(parp1_et.aov)

## PHF8 and ER and Type
df_ddx21_et_tcag_gtex_er_type_summary <- summarySE(df_et_tcag_gtex_er_type_com, measurevar="DDX21", groupvars=c("ER",'Type'))
p <- ggplot(df_ddx21_et_tcag_gtex_er_type_summary, aes(x = as.factor(ER), fill= Type)) +
  geom_boxplot(aes(
      lower = DDX21 - se,
      upper = DDX21 + se,
      middle = DDX21,
      ymin = DDX21 - 2*se,
      ymax = DDX21 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(df_et_tcag_gtex_er_type_com$DDX21), linetype = 2) + labs(y="RPKM",x="PAM") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) + scale_y_continuous(limits=c(3.5,5))
jpeg('figures/DDX21_breast_correlation_ER_TYPE_boxplot.jpg')
p
dev.off()

ddx21_et.aov = aov(DDX21 ~ ER + Type, data=df_ddx21_et_tcag_gtex_er_type_summary)
summary(ddx21_et.aov)
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

### Type
df_et_tcag_type <- df_et_tcag_gtex_type[which(df_et_tcag_gtex_type$Type %in% c('Primary Tumor','Solid Tissue Normal')),]
df_et_tcag_type$PARP1 <- log(df_et_tcag_type$PARP1,2)
df_et_tcag_type$DDX21 <- log(df_et_tcag_type$DDX21,2)

## PARP1 and Type
df_et_tcag_gtex_type_summary <- summarySE(df_et_tcag_type, measurevar="PARP1", groupvars=c("Type"))
p <- ggplot(df_et_tcag_gtex_type_summary, aes(x = as.factor(Type), fill= Type)) +
  geom_boxplot(aes(
      lower = PARP1 - se,
      upper = PARP1 + se,
      middle = PARP1,
      ymin = PARP1 - 2*se,
      ymax = PARP1 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(df_et_tcag_type$PARP1), linetype = 2) + labs(y="RPKM",x="PARP1") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1))
jpeg('figures/PARP1_breast_correlation_nvc_boxplot.jpg')
p
dev.off()

parp1_type.aov = aov(PARP1 ~ Type,data=df_et_tcag_type)
summary(parp1_type.aov)

## DDX21 and Type
df_ddx21_et_tcag_gtex_type_summary <- summarySE(df_et_tcag_type, measurevar="DDX21", groupvars=c("Type"))

p <- ggplot(df_ddx21_et_tcag_gtex_type_summary, aes(x = as.factor(Type), fill= Type)) +
  geom_boxplot(aes(
      lower = DDX21 - se,
      upper = DDX21 + se,
      middle = DDX21,
      ymin = DDX21 - 2*se,
      ymax = DDX21 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(df_et_tcag_type$DDX21), linetype = 2) + labs(y="RPKM",x="DDX21") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1)) +  scale_y_continuous(limits=c(3.8,4.9))
jpeg('figures/DDX21_breast_correlation_nvc_boxplot.jpg')
p
dev.off()

ddx21_type.aov = aov(DDX21 ~ Type,data=df_et_tcag_type)
summary(ddx21_type.aov)
Venkat Malladi's avatar
Venkat Malladi committed
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313

### Stage TCGA
pd_tcga_breast_stage <- pd_tcga_breast[complete.cases(pd_tcga_breast[ , 4]),]
pd_tcga_breast_stage$Stage[pd_tcga_breast_stage$Stage == 'Stage IA'] <- 'Stage I'
pd_tcga_breast_stage$Stage[pd_tcga_breast_stage$Stage == 'Stage IB'] <- 'Stage I'
pd_tcga_breast_stage$Stage[pd_tcga_breast_stage$Stage == 'Stage IIA'] <- 'Stage II'
pd_tcga_breast_stage$Stage[pd_tcga_breast_stage$Stage == 'Stage IIB'] <- 'Stage II'
pd_tcga_breast_stage$Stage[pd_tcga_breast_stage$Stage == 'Stage IIIA'] <- 'Stage III'
pd_tcga_breast_stage$Stage[pd_tcga_breast_stage$Stage == 'Stage IIIB'] <- 'Stage III'
pd_tcga_breast_stage$Stage[pd_tcga_breast_stage$Stage == 'Stage IIIC'] <- 'Stage III'
pd_tcga_breast_stage_known <- pd_tcga_breast_stage[ ! pd_tcga_breast_stage$Stage %in% c('Stage Tis','Stage X'), ]

pd_tcga_breast_stage_known$PARP1 <- log2(pd_tcga_breast_stage_known$PARP1)
pd_tcga_breast_stage_known$DDX21 <- log2(pd_tcga_breast_stage_known$DDX21)

## PARP1 and Stage
df_tcga_parp1_stage <- summarySE(pd_tcga_breast_stage_known, measurevar="PARP1", groupvars=c("Stage"))
p <- ggplot(df_tcga_parp1_stage, aes(x = as.factor(Stage), fill= Stage)) +
  geom_boxplot(aes(
      lower = PARP1 - se,
      upper = PARP1 + se,
      middle = PARP1,
      ymin = PARP1 - 2*se,
      ymax = PARP1 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(pd_tcga_breast_stage_known$PARP1), linetype = 2) + labs(y="RPKM",x="PARP1") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1))
jpeg('figures/PARP1_breast_correlation_stage_boxplot.jpg')
p
dev.off()

parp1_stage.aov = aov(PARP1 ~ Stage ,data=pd_tcga_breast_stage_known)
summary(parp1_stage.aov)

## DDX21 and Stage
df_tcga_ddx21_stage <- summarySE(pd_tcga_breast_stage_known, measurevar="DDX21", groupvars=c("Stage"))
p <- ggplot(df_tcga_ddx21_stage, aes(x = as.factor(Stage), fill= Stage)) +
  geom_boxplot(aes(
      lower = DDX21 - se,
      upper = DDX21 + se,
      middle = DDX21,
      ymin = DDX21 - 2*se,
      ymax = DDX21 + 2*se),
    stat = "identity",lwd=1.5) + geom_hline(yintercept = mean(pd_tcga_breast_stage_known$DDX21), linetype = 2) + labs(y="RPKM",x="DDX21") + theme_bw() + theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.ticks=element_line(size=1))
jpeg('figures/DDX21_breast_correlation_stage_boxplot.jpg')
p
dev.off()

ddx21_stage.aov = aov(DDX21 ~ Stage,data=pd_tcga_breast_stage_known)
summary(ddx21_stage.aov)