diff --git a/src/.docker_modules/r-bolero/1.0/HBV_RNAs_count.R b/src/.docker_modules/r-bolero/1.0/HBV_RNAs_count.R
index 5d0d29c7ee71dbcf5887fe66150c5156cac7298f..af077b27a950e5f7af809c14690819db6c5ea880 100644
--- a/src/.docker_modules/r-bolero/1.0/HBV_RNAs_count.R
+++ b/src/.docker_modules/r-bolero/1.0/HBV_RNAs_count.R
@@ -68,6 +68,7 @@ clean_SP <- identified_SP[!duplicated(identified_SP$id),] %>%
   select(id, mapQ, transcript_strand, JAQ, barcode, promoter, junction, SP_name)
 
 countSP <- clean_SP %>% count(SP_name)
+countSP$SP_name <- factor(countSP$SP_name)
 countSP <- dplyr::inner_join(palette_complete, 
                       countSP, 
                       by = c("nom" = "SP_name"))
@@ -78,35 +79,37 @@ countSP$nom <- factor(countSP$nom, levels = all_species_name)
 countSP <- dplyr::mutate(countSP,
                   proportion = (as.numeric(n)/sum(as.numeric(n))*100))
 #print(countSP)
-ggplot(countSP, aes(x = "percent", 
-                    y = proportion,
-                    fill = nom)) +
-  geom_col() +
-  coord_polar("y") +
-  scale_fill_manual(values = countSP$teinte) +
-  labs(fill = "spliced-variants")
-
-ggsave(file = paste0(opt$barcode, "_SP_proportion_piechart.png"),
-       scale = 2,
-       width = 1920,
-       height = 1080,
-       units = "px",
-       dpi = 300)
-
-ggplot(countSP, aes(x = nom, y = proportion, fill = nom)) +
-  geom_col() +
-  scale_fill_manual(values = countSP$teinte) + 
-  theme(axis.text.x = element_text(angle = 45)) +
-  labs(fill = "spliced-variants") +
-  xlab(label = "spliced-variants") +
-  ylab(label = "percent")
-
-ggsave(file = paste0(opt$barcode, "_SP_proportion.png"),
-       scale = 2,
-       width = 1920,
-       height = 1080,
-       units = "px",
-       dpi = 300)
+if (length(countSP$nom) != 0) {
+  ggplot(countSP, aes(x = "percent", 
+                      y = proportion,
+                      fill = nom)) +
+    geom_col() +
+    coord_polar("y") +
+    scale_fill_manual(values = countSP$teinte) +
+    labs(fill = "spliced-variants")
+  
+  ggsave(file = paste0(opt$barcode, "_SP_proportion_piechart.png"),
+         scale = 2,
+         width = 1920,
+         height = 1080,
+         units = "px",
+         dpi = 300)
+  
+  ggplot(countSP, aes(x = nom, y = proportion, fill = nom)) +
+    geom_col() +
+    scale_fill_manual(values = countSP$teinte) + 
+    theme(axis.text.x = element_text(angle = 45)) +
+    labs(fill = "spliced-variants") +
+    xlab(label = "spliced-variants") +
+    ylab(label = "percent")
+  
+  ggsave(file = paste0(opt$barcode, "_SP_proportion.png"),
+         scale = 2,
+         width = 1920,
+         height = 1080,
+         units = "px",
+         dpi = 300)
+}
 
 # TSS not spliced:
 classified_reads <- read.table(file = opt$classification, 
@@ -235,6 +238,7 @@ count_clear <- clean_SP[clean_SP$SP_name %in% SPvariants,] %>% count(SP_name)
 count_clear <- dplyr::mutate(count_clear,
                       proportion=(as.numeric(n)/sum(as.numeric(n))*100))
 #print(count_clear)
+count_clear$SP_name <- factor(count_clear$SP_name)
 count_clear <- dplyr::inner_join(palette_complete,
                           count_clear, 
                           by = c("nom" = "SP_name"))