Commit ae680395 authored by Antonio Politi's avatar Antonio Politi
Browse files

R code for plotting life cell results 2018

parent 975fdcfd
# script to plot live cell data acquired for
# Shotaro et al. 2016 eLife paper
library("Hmisc")
library("ggplot2")
library(reshape)
library(cowplot)
# -----
if (Sys.info()['sysname'] == 'Darwin'){
indatadir <-'/Users/toni/Dropbox/NPCMaturation/expdata/livecell'
indir <- '/Users/toni/Dropbox/NPCMaturation/results/livecell'
outdir <- '/Users/toni/Dropbox/NPCMaturation/results/livecell/figures'
} else {
indatadir <- 'C:\\Users\\toni\\Dropbox\\NPCMaturation\\expdata/livecellCalibrated/'
indir <- 'C:\\Users\\toni\\Dropbox\\NPCMaturation\\results\\fitnups_2018/'
outdir <- 'C:\\Users\\toni\\Dropbox\\NPCMaturation\\results\\fitnups_2018/'
}
datain <-read.csv(file.path(indatadir, 'HeLa4D-core-noncore-normalized-summary-180104.txt'), sep='\t')
# -----
cols <- c('#20BCEF', '#A2C964' )
for (POI in unique(datain$POI)){
modelin <- read.csv(file.path(outdir, paste('simulated_fixedpar_', POI, '.csv', sep = '')), sep = '\t', skip = 3)
p1 <- ggplot(data = datain[(datain$POI ==POI) & (datain$region == 'non-core'),],
aes(x = TIME, y = AVG)) + geom_point( shape = 17, color = cols[1]) +
geom_ribbon(aes(ymin = AVG-SD, ymax= AVG+SD), fill = cols[1], alpha =0.5, na.rm = TRUE) +
geom_line(data = modelin, aes(x = time, y = NC), color = cols[1], size = 1.5 ) + theme_classic(base_size = 10) + ylab('Total normalized intensity') +
xlab('Time after AO (min)') + coord_cartesian(xlim = c(0,125), ylim = c(0,1.25))
p1
p2 <- ggplot(data = datain[(datain$POI == POI) & (datain$region == 'core'),],
aes(x = TIME, y = AVG)) + geom_point( shape = 17, color = cols[2]) +
geom_ribbon(aes(ymin = AVG-SD, ymax= AVG+SD), fill = cols[2], alpha =0.5,na.rm = TRUE) +
geom_line(data = modelin, aes(x = time, y = C), color = cols[2], size = 1.5 ) + theme_classic(base_size = 10) + ylab('Total normalized intensity') +
xlab('Time after AO (min)') + coord_cartesian(xlim = c(0,125), ylim = c(0,1.25))
p2
p <- plot_grid(p1+ggtitle(POI),p2, nrow = 2)
ggsave(p, filename = file.path(outdir, paste('simulated_fixedpar_', POI, '.png', sep = '')),
height = 5, width = 3)
}
# ----
#plot all ip assembly in one graph
model_allp <- data.frame()
par_allp <- data.frame()
for (POI in unique(datain$POI)){
modelin <- read.csv(file.path(outdir, paste('simulated_fixedpar_', POI, '.csv', sep = '')), sep = '\t', skip = 3)
modelin$POI <- POI
parin <- read.csv(file.path(outdir, paste('simulated_fixedpar_', POI, '.csv', sep = '')), sep = ' ', skip = 1, nrows = 1, header = F)
parin <- parin[1:10]
colnames(parin) <- c('k1_pm', 'k2_pm', 'k1_ip', 'k2_ip' , 'NC_frac_pm', 'C_frac_pm',
'factProd_NC_p1' ,'factPro_NC_p2', 'factProd_C_p1', 'factPro_C_p2')
parin$POI <- POI
if (POI %in% c('Seh1'))
parin$tau <- 1/parin$k1_ip
else
parin$tau <- 1/parin$k1_ip + 1/parin$k2_ip
if (POI %in% c('Seh1', 'Nup107', 'Nup153')) {
modelin$group <- '1'
}
if (POI %in% c('Nup205', 'Nup62')) {
modelin$group <- '2'
}
if (POI %in% c('Nup214', 'Nup358')) {
modelin$group <- '3'
}
if (POI %in% c('Tpr')) {
modelin$group <- '4'
}
par_allp <- rbind(parin, par_allp)
model_allp <- rbind(model_allp, modelin)
}
par_allp[order(par_allp$tau), 'POI']
model_allp$POI <- factor(model_allp$POI, levels = par_allp[order(par_allp$tau), 'POI'])
par_allp$POI <- factor(par_allp$POI, levels = par_allp[order(par_allp$tau), 'POI'])
p <- ggplot(data = model_allp,
aes(x = time, y = C_ip_pure, color = POI)) + geom_line() +
theme_classic(base_size = 10) + ylab('Total normalized intensity') +
xlab('Time after AO (min)')
p
p <- ggplot(data = par_allp,
aes(x = POI, y = tau, fill = POI)) + geom_bar(stat = 'identity') +
theme_classic(base_size = 10) + ylab('Characteristic interphase assembly time (min)') +
xlab('POI')
p
# -----
# -----
plotDataAll <-function(d1,d2, simul, names, cols, alpha, fname) {
# function to plot data no separation between interphase and postmitotic
pdf(fname, width = 2.8, height=2, useDingbats = F,pointsize = 8, paper="special", fonts="Helvetica")
lw<- 2
par(mar=c(4, 4, 1,1), mgp=c(2.5,1,0))
plot(d1$x, d1$y, xlab = "", ylab = "Normalized total intensity",
type = "n", yaxt = 'n', xaxt = 'n', xlim = c(0, 120), ylim = c(0, 1.4), bty='l')
#title('NUP107 inner-core region')
axis(1, tck = -0.05, at=c(0,20,40,60,80,100,120))
axis(2, las=2, tck =-0.05, at=c(0,0.2,0.4,0.6,0.8,1,1.2))
mtext(side=1, text="Time after AO (min)", line=2)
#transparent colors
cols1_t <-adjustcolor(cols[1], alpha.f = alpha)
cols2_t <-adjustcolor(cols[2], alpha.f = alpha)
#plot data for Non-core and core region
polygon(c(d1$x, rev(d1$x)), c(d1$upper, rev(d1$lower)), col = cols1_t, border = NA)
polygon(c(d1$x, rev(d1$x)), c(d2$upper, rev(d2$lower)), col = cols2_t, border = NA)
points(d1$x, d1$y, pch = 17, col = cols[1], cex=0.6)
points(d1$x, d2$y, pch = 17, col = cols[2], cex=0.6)
#plot simulations
lines(simul[,names[1]], simul[,names[2]], lwd = lw, col = cols[1])
lines(simul[,names[1]], simul[,names[3]], lwd = lw, col = cols[2])
par(xpd=TRUE)
legend(0,1.65, c("Non-core", "Inner-core","Non-core model", "Inner-core model"),
lwd = c(0,0, 1.5,1.5), pch = c(17,17, -1,-1), lty = c(0,0, 1,1),
col= c(cols[1], cols[2], cols[1], cols[2]), horiz = F, bty='n',
y.intersp = 0.88, cex = 0.88)
dev.off()
}
# -----
plotData_IP <-function(simul1, simul2, names, cols, fname) {
pdf(fname, width = 2.8, height=2, useDingbats = F,pointsize = 8, paper="special", fonts="Helvetica")
lw<- 2
par(mar=c(4, 4, 1,1), mgp=c(2.5,1,0))
plot(simul1[,names[1]], simul1[,names[2]], xlab = "", ylab = "Normalized interphase density",
type = "n", yaxt = 'n', xaxt = 'n', xlim = c(0, 120), ylim = c(0, 1.1), bty='l')
axis(1, tck = -0.05, at=c(0,20,40,60,80,100,120))
axis(2, las=2, tck =-0.05, at=c(0,0.2,0.4,0.6,0.8,1))
mtext(side=1, text="Time after AO (min)", line=2)
lines(simul1[,names[1]], simul1[,names[2]], lwd = lw, lty = 1, col = cols[1])
lines(simul2[,names[1]], simul2[,names[2]], lwd = lw, lty = 1, col = cols[2])
par(xpd=TRUE)
legend(0,1.1, c("Nup107", "Nup358"),
lwd = c(1.5,1.5),
col=c(cols[1], cols[2]), horiz = F, bty='n',
y.intersp = 0.88, cex = 0.88)
dev.off()
}
# ----
nc107 <- data.frame('x'= datain$time, 'y' = datain$NUP107_NC, 'upper'=datain$NUP107_NC + datain$NUP107_NC_std,
'lower' = datain$NUP107_NC - datain$NUP107_NC_std)
c107 <- data.frame('x'= datain$time, 'y' = datain$NUP107_C, 'upper'=datain$NUP107_C + datain$NUP107_C_std,
'lower' = datain$NUP107_C - datain$NUP107_C_std)
nc358 <- data.frame('x'= datain$time, 'y' = datain$NUP358_NC, 'upper'=datain$NUP358_NC + datain$NUP358_NC_std,
'lower' = datain$NUP358_NC - datain$NUP358_NC_std)
c358 <- data.frame('x'= datain$time, 'y' = datain$NUP358_C, 'upper'=datain$NUP358_C + datain$NUP358_C_std,
'lower' = datain$NUP358_C - datain$NUP358_C_std)
plotDataAll(nc107, c107, simulNUP107, c('time','NC', 'C'), c('#20BCEF', '#A2C964' ), 0.4, 'NUP107.pdf')
plotDataAll(nc358, c358, simulNUP358, c('time','NC', 'C'), c('#20BCEF', '#A2C964' ), 0.4, 'NUP358.pdf')
plotDataF(nc107, simulNUP107, c('time','NC', 'NC_pm', 'NC_ip'), c('#20BCEF', 'gray20'), 0.4, 'NUP107_NC.pdf')
plotDataF(c107, simulNUP107, c('time','C', 'C_pm', 'C_ip'), c('#A2C964', 'gray20'), 0.4, 'NUP107_C.pdf')
plotDataF(nc358, simulNUP358, c('time','NC', 'NC_pm', 'NC_ip'), c('#20BCEF', 'gray20' ), 0.4, 'NUP358_NC.pdf')
plotDataF(c358, simulNUP358, c('time','C', 'C_pm', 'C_ip'), c('#A2C964', 'gray20'), 0.4, 'NUP358_C.pdf')
plotData_IP(simulNUP107, simulNUP358, c('time','C_ip_density'), c('#A2C964' , '#d01c8b'), 'NUP107_358_C_den.pdf' )
#c('#A2C964', '#C1FF00')
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment