From 833f1697ea394b577fbcebac77c14e2ca7fda859 Mon Sep 17 00:00:00 2001 From: Jorrit Boekel Date: Mon, 3 Apr 2023 15:12:07 +0200 Subject: [PATCH] Put if statement around plotting in case the lists are empty --- SpectrumAI.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SpectrumAI.R b/SpectrumAI.R index 5f4177e..cd0ddbc 100755 --- a/SpectrumAI.R +++ b/SpectrumAI.R @@ -210,8 +210,12 @@ saav_psm_failed = df.sub[df.sub$flanking_ions_support=="NO",]$PrecursorError.ppm pdf("precursorError.histogram.plot.pdf",width = 10, height = 7) par(mfrow=c(1,2)) -hist(saav_psm_passed,breaks=20,xlab="precMassError (ppm)",main="SpectrumAI curated") -hist(saav_psm_failed,breaks=20,xlab="precMassError (ppm)",main="SpectrumAI discarded") +if (length(saav_psm_passed)) { + hist(saav_psm_passed,breaks=20,xlab="precMassError (ppm)",main="SpectrumAI curated") +} +if (length(saav_psm_failed)) { + hist(saav_psm_failed,breaks=20,xlab="precMassError (ppm)",main="SpectrumAI discarded") +} dev.off() end.time <- Sys.time()