Skip to content

Commit

Permalink
updated vignette with correct size font in figs
Browse files Browse the repository at this point in the history
  • Loading branch information
lmsimp committed Jul 8, 2021
1 parent c6ae40d commit 5fb6f9b
Show file tree
Hide file tree
Showing 6 changed files with 1,745 additions and 1,804 deletions.
8 changes: 4 additions & 4 deletions R/intersection.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ compareDatasets <- function(MSnSet,


## plot heatmap of assignments
ggheatmap <- function(df, title = ""){
ggheatmap <- function(df, title = "", size = 24){
ggplot(df, aes(loc_hl, loc_dc, fill=100*ref_dc)) +
geom_tile(colour="grey80") +
geom_text(aes(label=overlap), size=8) +
geom_text(aes(label=overlap), size=3) +
# theme(axis.text.x=element_text(angle=90, vjust=0.5, hjust=1)) +
scale_fill_gradient(low="white", high="steelblue",
name="% Intersection\ntagm",
Expand All @@ -66,8 +66,8 @@ ggheatmap <- function(df, title = ""){
axis.title.y = element_text(margin = margin(t = 0, r = -18,
b = 0, l = 0))) +
theme(axis.text.x=element_text(angle=45, vjust=1, hjust=1)) +
theme(text = element_text(size=24),
legend.text = element_text(size=18),
theme(text = element_text(size=size),
legend.text = element_text(size=size-1),
axis.text.x = element_text(colour = "black"),
axis.text.y = element_text(colour = "black")) +
ggtitle(title)
Expand Down
46 changes: 23 additions & 23 deletions R/plotCD14_profiles.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
pdf(file = "../figures_thp_june2021/figures/cd14-unst.pdf", width = 12, height = 7)
data <- unst
# pdf(file = "../figures_thp_june2021/figures/cd14-unst.pdf", width = 12, height = 7)
# data <- unst
# # sampleNames(data) <- paste0(pData(data)$Tag, "_Replicate_", pData(data)$Replicate, "_Set", pData(data)$Set)
# sampleNames(data) <- paste0(pData(data)$Fraction, "_", pData(data)$Tag, "_Set", pData(data)$Set, "_Rep_", pData(data)$Replicate)
# .sel <- which(fData(data)$markers == "Plasma Membrane")
# fData(data)$foi <- "unknown"
# fData(data)$foi[which(fData(data)$GN == "CD14")] <- "CD14"
# fData(data)$foi[.sel] <- "Plasma Membrane"
# col <- c("black", "#D55E00")
# plotProfiles(data, fcol = "foi")
# dev.off()
#
# pdf(file = "../figures_thp_june2021/figures/cd14-lps.pdf", width = 12, height = 7)
# data <- lps
# # sampleNames(data) <- paste0(pData(data)$Tag, "_Replicate_", pData(data)$Replicate, "_Set", pData(data)$Set)
# sampleNames(data) <- paste0(pData(data)$Fraction, "_", pData(data)$Tag, "_Set", pData(data)$Set, "_Rep_", pData(data)$Replicate)
# .sel <- which(fData(data)$markers == "Plasma Membrane")
# fData(data)$foi <- "unknown"
# fData(data)$foi[which(fData(data)$GN == "CD14")] <- "CD14"
# fData(data)$foi[.sel] <- "Plasma Membrane"
# col <- c("black", "#D55E00")
# sampleNames(data) <- paste0(pData(data)$Tag, "_Replicate_", pData(data)$Replicate, "_Set", pData(data)$Set)
sampleNames(data) <- paste0(pData(data)$Fraction, "_", pData(data)$Tag, "_Set", pData(data)$Set, "_Rep_", pData(data)$Replicate)
.sel <- which(fData(data)$markers == "Plasma Membrane")
fData(data)$foi <- "unknown"
fData(data)$foi[which(fData(data)$GN == "CD14")] <- "CD14"
fData(data)$foi[.sel] <- "Plasma Membrane"
col <- c("black", "#D55E00")
plotProfiles(data, fcol = "foi")
dev.off()

pdf(file = "../figures_thp_june2021/figures/cd14-lps.pdf", width = 12, height = 7)
data <- lps
# sampleNames(data) <- paste0(pData(data)$Tag, "_Replicate_", pData(data)$Replicate, "_Set", pData(data)$Set)
sampleNames(data) <- paste0(pData(data)$Fraction, "_", pData(data)$Tag, "_Set", pData(data)$Set, "_Rep_", pData(data)$Replicate)
.sel <- which(fData(data)$markers == "Plasma Membrane")
fData(data)$foi <- "unknown"
fData(data)$foi[which(fData(data)$GN == "CD14")] <- "CD14"
fData(data)$foi[.sel] <- "Plasma Membrane"
col <- c("black", "#D55E00")
sampleNames(data) <- paste0(pData(data)$Tag, "_Replicate_", pData(data)$Replicate, "_Set", pData(data)$Set)
plotProfiles(data, fcol = "foi")
dev.off()
# plotProfiles(data, fcol = "foi")
# dev.off()

plotProfiles <- function(data,
fcol = "foi",
Expand Down
4 changes: 2 additions & 2 deletions R/plotLineGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ plotLineGraph <- function(data, fun = c("mean", "median"),
else (stop(message(paste("Summary stat specified must be mean or median"))))

p <- ggplot(sum_dat, aes(x=Time, y=measurement)) +
geom_line(size = 1.3, color = linecol) +
geom_point(size = 4, color = linecol) +
geom_line(size = 1, color = linecol) +
geom_point(size = 1.5, color = linecol) +
scale_x_discrete(limits = seq(0, 24, by = 2)) +
xlab("\nTime (hours)") +
ylab(.ylab) +
Expand Down
88 changes: 1 addition & 87 deletions R/plotRibbons.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,90 +58,4 @@ ribbonPlot <- function(profs, col = "red", q = c(0, 1), size = 1.6, ...) {
type = "l")


}

## =====================PROFILES plot========================
## ==========================================================




plotRibbons2 <- function(msnset,
fcol = "loc.pred",
mrkClasses,
grid = FALSE,
unknowns = FALSE,
mycols = mycol) {

profs <- exprs(msnset)
if(missing(mrkClasses)) {
mrkClasses <- getMarkerClasses(msnset)
}
indMrk <- lapply(mrkClasses, function(x) which(fData(msnset)[, "loc.pred"] == x))

# browser()
par(mar = c(13, 4, 1, 1), oma = c(0, 0, 0, 0))
ylim <- c(0.05,.4)
n <- nrow(profs)
m <- ncol(profs)
fracs <- colnames(profs)
## check if there are replicates and if their are, create breaks in the plot
# if (!is.null(pcol)) {
# repInfo <- unique(pd[, pcol])
# repNames <- vector("list", length(repInfo))
# ## get fraction names by replicate
# fracNames <- lapply(repInfo, function(z) colnames(profs)[pd$Experiment == z])
# fracInds <- lapply(fracNames, function(z) which(z == colnames(profs)))
# } else {
fracInds <- list(seq(colnames(profs)))
# }
## get unknowns
profs_un <- profs[which(fData(msnset)[, fcol] == "unknown"), ]
## get quantiles for each fraction in unknowns
quants <- apply(profs_un, MARGIN = 2, function(x)
quantile(x, c(0, 1), na.rm = TRUE)) # max and min for unknowns
bound_low <- quants[1, ]
bound_high <- quants[2, ]
## get quantiles for subcellular classes
mrkProfs <- lapply(indMrk, function(z) profs[z, , drop = FALSE]) # 5% and 95% quantiles for all other classes
quants <- lapply(mrkProfs, function(z) apply(z, MARGIN = 2, function(x)
quantile(x, c(0.25, .75), na.rm = TRUE)))
meanProfs <- lapply(mrkProfs, function(z) apply(z, 2, mean, na.rm = TRUE))
## make polygon plots
plot(0, ylim = ylim, xlim = c(1, m),
type = "n", xaxt = "n", yaxt = "n", xlab = "",
ylab = "Intensities", cex.axis = 1.2,
cex.lab = 1.2)
v_x <- axis(1, at = 1:m, labels = fracs, las = 2, cex.axis = 1.2)
v_y <- axis(2)
if (grid) abline(v = v_x, h = v_y, lty = "dotted", col = "lightgray", lwd = 1)
mtext("Fractions", side=1, line=8, cex = 1.2)
## update lines on plot according to zoom
# feats <<- which(brushBounds$i & brushBounds$j)
# namFeats <- names(feats)[which(names(feats) %in% rownames(profs_un))]

## plot unknowns
if (unknowns) {
invisible(lapply(fracInds, function(x) # plot all unknowns as lines here
matlines(x, t(profs_un),
col = "grey90", lty = 1, lwd = 1, type = "l")
))
}
## markers

for (i in 1:length(indMrk)) {
if (!is.na(indMrk[[i]][1])) {
invisible(lapply(fracInds, function(x) # don't plot all lines
polygon(c(x, rev(x)),
c(quants[[i]][2, x], rev(quants[[i]][1, x])),
col = paste0(mycol[i], 60), border = FALSE)
))
invisible(lapply(fracInds, function(z) # plot the mean profile
matlines(z, meanProfs[[i]][z],
col = mycol[i],
lty = 1, lwd = 1,
type = "l")))
}
}

} ## ----------- end of function----------------
}
Loading

0 comments on commit 5fb6f9b

Please sign in to comment.