Skip to content

Commit

Permalink
Changed PNG type to 'cairo' to avoid crash when X11 server is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-sturm committed Jul 7, 2021
1 parent 3df2421 commit 355c97d
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion PCAWG/mCNV_calling.R
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ for (h in 0:(2 * len + 1)) {



png(filename=CNV_name_to_write, width = 640, height = 640)
png(filename=CNV_name_to_write, type = "cairo", width = 640, height = 640)

plot(trans_values, ylim=c(0, max(trans_values) + 0.5), ylab="Copy Number", xlab="Samples from the largest cohort", main=CNV_name)
abline(h=location)
Expand Down
2 changes: 1 addition & 1 deletion PCAWG/mCNV_mature_genotyping.R
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ for (h in 0:(2 * len + 1)) {



png(filename=CNV_name_to_write, width = 640, height = 640)
png(filename=CNV_name_to_write, type = "cairo", width = 640, height = 640)

plot(trans_values, ylim=c(0, max(trans_values) + 0.5), ylab="Copy Number", xlab="Samples from the largest cohort", main=CNV_name)
abline(h=location)
Expand Down
2 changes: 1 addition & 1 deletion PCAWG/normalization.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ rect.hclust(hc, k=num_of_clusters, border="red")


plotDataFile <- function(x, functionType) {
png("data.file.png", width = 2500, height = 1600, pointsize=32)
png("data.file.png", type = "cairo", width = 2500, height = 1600, pointsize=32)
if (identical(functionType, plot)) {
functionType(x, pch=19, col=rgb(0,0,0,0.1))
} else {
Expand Down
2 changes: 1 addition & 1 deletion PCAWG/rCNV_calling_snp1.R
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ for (h in 0:(2 * len + 1)) {

pr = F
if (pr) {
png(filename=CNV_name_to_write, width = 640, height = 640)
png(filename=CNV_name_to_write, type = "cairo", width = 640, height = 640)

plot_st <- max(1,st - length_of_repr)
plot_fn <- min(ncol(resid), fn + length_of_repr)
Expand Down
Empty file modified clinCNV.R
100755 → 100644
Empty file.
Empty file modified generalHelpers.R
100755 → 100644
Empty file.
12 changes: 6 additions & 6 deletions germline/helpersGermline.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Determine.gender <- function(normalized.coverage.corrected.gc, probes) {
clusters <- clKmeans$cluster
clusters[clusters == 1] <- "F"
clusters[clusters == 2] <- "M"
png(filename=paste0(opt$out, paste0("/genders.png")), width=800, height=800)
png(filename=paste0(opt$out, paste0("/genders.png")), type = "cairo", width=800, height=800)
plot(matrix_of_values, col = clKmeans$cluster, xlab="Y Chromsome", ylab="X Chromosome", pch=19, cex=2)
points(clKmeans$centers, col = 1:2, pch = 8, cex = 10)
dev.off()
Expand Down Expand Up @@ -480,7 +480,7 @@ returnClustering <- function(minNumOfElemsInCluster) {
print(paste("You ask to clusterise intro clusters of size", minNumOfElemsInCluster, "but size of the cohort is", ncol(normal), "which is not enough. We continue without clustering."))

setwd(opt$out)
png(filename="clusteringSolution.png", width=1024, height=1024)
png(filename="clusteringSolution.png", type = "cairo", width=1024, height=1024)
plot(x, y, xlab="Coordinate 1", ylab="Coordinate 2",
main="Isometric MDS", type="n")
text(x, y, labels = colnames(normal), cex=.7, col=clustering + 1)
Expand Down Expand Up @@ -567,7 +567,7 @@ returnClustering <- function(minNumOfElemsInCluster) {


setwd(opt$out)
png(filename="clusteringSolution.png", width=1024, height=1024)
png(filename="clusteringSolution.png", type = "cairo", width=1024, height=1024)
plot(x, y, xlab="Coordinate 1", ylab="Coordinate 2",
main="Isometric MDS", type="n")
text(x, y, labels = row.names(distMatrix), cex=.7, col=clustering + 1)
Expand Down Expand Up @@ -621,7 +621,7 @@ returnTreeForCorrelation <- function(coverage.normalised.local, sdsOfGermlineSam
trainingDataset = trainingDataset[-which(distnacesClose > 1000),]
if (nrow(trainingDataset) > 100 & nrow(unique(trainingDataset)) > 10) {
fit <- ctree(covariancesClose ~ (distnacesClose) + (sumOfLengths) + minLength + maxLength, data=trainingDataset, control=ctree_control(mincriterion = 0.99))
png(filename="treeOnCorrelationOfCoverage.png", width=4000, height=1800)
png(filename="treeOnCorrelationOfCoverage.png", type = "cairo", width=4000, height=1800)
plot(fit)
dev.off()
} else {
Expand Down Expand Up @@ -885,7 +885,7 @@ returnClustering2 <- function(minNumOfElemsInCluster) {
print(paste("You ask to clusterise intro clusters of size", minNumOfElemsInCluster, "but size of the cohort is", ncol(normal), "which is not enough. We continue without clustering."))

setwd(opt$out)
png(filename="clusteringSolution.png", width=1024, height=1024)
png(filename="clusteringSolution.png", type = "cairo", width=1024, height=1024)
plot(x, y, xlab="Coordinate 1", ylab="Coordinate 2",
main="UMAP", type="n")
text(x, y, labels = colnames(normal), cex=.7, col=clustering + 1)
Expand Down Expand Up @@ -935,7 +935,7 @@ returnClustering2 <- function(minNumOfElemsInCluster) {
palleteToPlot = rainbow(max(clustering))
colsToPlot = sapply(1:length(clustering), function(i){palleteToPlot[clustering[i]]})
setwd(opt$out)
png(filename="clusteringSolution.png", width=1024, height=1024)
png(filename="clusteringSolution.png", type = "cairo", width=1024, height=1024)
plot(x, y, xlab="Coordinate 1", ylab="Coordinate 2",
main="UMAP", type="n")
text(x, y, labels = row.names(distMatrix), cex=.7, col=colsToPlot)
Expand Down
2 changes: 1 addition & 1 deletion germline/mCNVhelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ findFinalState <- function(coverageNeededToCheck, toyBedFilePolymorphCurrent, mu
diagnosticPlot = (length(which(copy_number != as.numeric(names(sort(table(copy_number),decreasing=TRUE)[1])))) >= 0.05 * length(copy_number))
if (diagnosticPlot == T & plotting) {
fileName = paste(numberOfClusterAnalysed, toyBedFilePolymorphCurrent[1,1], toyBedFilePolymorphCurrent[1,2], toyBedFilePolymorphCurrent[nrow(toyBedFilePolymorphCurrent),3], sep="_")
png(paste0(folder_name_mcnv, fileName, ".png"), width=length(copy_number) * 3, height=800)
png(paste0(folder_name_mcnv, fileName, ".png"), type = "cairo", width=length(copy_number) * 3, height=800)
plot(coverageSummarised ** 2 * bestDivisor, col="black", pch=21,bg=coloursP[(copy_number + 1)])
abline(h=bestLoc ** 2 * bestDivisor)
dev.off()
Expand Down
Empty file modified mergeFilesFromFolder.R
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions somatic/bafSegmentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ determineAllowedChroms <- function(healthySample, tumorSample, healthySampleName
subDir = paste0(tumorSampleName, "_", healthySampleName)
dir.create(file.path(folderBAF, "result", subDir))
setwd(file.path(folderBAF, "result", subDir))
png(paste0(tumorSampleName, "_", healthySampleName, ".png"), width=1400, height=600)
png(paste0(tumorSampleName, "_", healthySampleName, ".png"), type = "cairo", width=1400, height=600)
op <- par(mar=c(11,4,4,2))
x <- barplot(evaluated, col=colVec, main=paste(tumorSampleName, healthySampleName, "expected proportion of BAF with p < 0.05:", round(pvalueShift, digits=3)), ylim=c(0,1), xaxt="n")
text(x-2.5, par("usr")[3] - 0.15, labels = plotLabels, srt = 45, pos = 1, xpd = TRUE)
Expand All @@ -262,7 +262,7 @@ determineAllowedChroms <- function(healthySample, tumorSample, healthySampleName
abline(h=0.1, lwd=2, col="red")
dev.off()

png("overdispersion.png", width=1024, height=1024)
png("overdispersion.png", type = "cairo", width=1024, height=1024)
plot(overdispersionFactorsNornm ~ overdispersionFactorsTum, main="Dispersion over Binomial")
dev.off()

Expand Down
6 changes: 3 additions & 3 deletions somatic/helpersSomatic.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ formilngLogFoldChange <- function(pairs, normalCov, tumorCov, currentBedFile, ge
predictions <- runmed(shiftsChrom, k = 51)
shifts[whichChrom] = predictions
}
png(paste0(opt$out, "/plot_with_shifts.png"), width=2000, height=1000)
png(paste0(opt$out, "/plot_with_shifts.png"), type = "cairo", width=2000, height=1000)
plot(shifts)
lines(shifts, col="red", lwd=3)
dev.off()
Expand Down Expand Up @@ -443,7 +443,7 @@ makeBarplot <- function(allPotentialPurities, found_CNVs_total, sample_name) {
}
datasetForBarplot = (datasetForBarplot / 10**6)
maxheight = max(datasetForBarplot)
png(paste0(sample_name, "_clonalityBarplot.png"), width=2400, height=640)
png(paste0(sample_name, "_clonalityBarplot.png"), type = "cairo", width=2400, height=640)
bp <- barplot(datasetForBarplot, col=c("brown","blue","darkblue","red") , font.axis=2, beside=T, main=paste("Presence of clones in tumor", sample_name, ", estimated purity: ", max(as.numeric(found_CNVs_total[,6]))), ylim=c(0, 1.05 * maxheight), xlab="Subclones investigated", ylab="Length, MB")
for (z in 1:ncol(datasetForBarplotNumber)) {
for (v in 1:nrow(datasetForBarplotNumber)) {
Expand Down Expand Up @@ -1063,7 +1063,7 @@ plotLikelihoodLandscape <- function(datasetOfPuritiesCopies, addressOfPlot, foun
local_purities, local_majorBAF, local_minorBAF, left_borders, right_borders, ends_of_chroms,
local_majorBAF_second, local_minorBAF_second, local_purities_second) {
colorsForCN = c(rgb(1,0,0,0.9), rgb(0.6470588, 0.1647059, 0.1647059, 0.9), rgb(0,0,1,0.9))
png(filename=addressOfPlot, width=2500, height=1000)
png(filename=addressOfPlot, type = "cairo", width=2500, height=1000)

linesOnBarplot = list()
orderOfNames = c(paste0("chr", 1:22), "chrX", "chrY")
Expand Down
3 changes: 1 addition & 2 deletions somatic/somaticCallingProcedure.R
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,7 @@ somaticCalling <- function(matrixOfLogFold) {
if (!finalIteration) {
do.call(file.remove, list(list.files(paste0(folder_name, sample_name), full.names = TRUE)))
}
png(filename = paste0(sample_name, "_clonality.png"),
width = 640, height = 640)
png(filename = paste0(sample_name, "_clonality.png"), type = "cairo", width = 640, height = 640)
heatmap((matrixOfClonalityForPlotting), scale="none", Rowv = NA, Colv = NA, col=hmcols, main=sample_name)
dev.off()

Expand Down

0 comments on commit 355c97d

Please sign in to comment.