Skip to content

Commit

Permalink
Fixed error (variables not existing) when none of FSM, ISM, NIC or NN…
Browse files Browse the repository at this point in the history
…C where present
  • Loading branch information
Fabian-RY committed Sep 18, 2024
1 parent 146327e commit 43070e3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 42 deletions.
56 changes: 28 additions & 28 deletions utilities/report_qc/SQANTI3_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,7 @@ if (nrow(data.junction) > 0 && nrow(x) > 0){
t3.RTS <- rbind(t3.RTS, c("ISM", TRUE, 0,0,0,"RT switching"))
}
if(!("NIC" %in% t3.RTS$structural_category)){
t3.RTS <- rbind(t3.RTS, c("NIC", TRUE, ,0,0,"RT switching"))
t3.RTS <- rbind(t3.RTS, c("NIC", TRUE, 0,0,0,"RT switching"))
}
if(!("NNC" %in% t3.RTS$structural_category)){
t3.RTS <- rbind(t3.RTS, c("NNC", TRUE,0,0,"RT switching"))
Expand Down Expand Up @@ -2252,37 +2252,37 @@ if (nrow(data.junction) > 0 && nrow(x) > 0){
t3.a <- rbind(t3.annot[,c(1,5,6)], t3.a.SJ[,c(1,5,6)], t3.a.Cov[,c(1,5,6)])

}

}

# Check if t3.SJ is not empty
if (nrow(t3.SJ) > 0) {
t3.aa <- rbind(t3.annot[,c("structural_category", "perc", "Var")], t3.a.SJ[,c(1,5,6)])

for(i in 1:length(t3.list)){
set=data.frame(t3.data.sets[i])
c=data.frame(t3.list[i])
if (!all(is.na(set))){
t.temp=t3.aa
t3.aa = rbind(t.temp, c[,c(1,5,6)])
# Check if t3.SJ is not empty
if (nrow(t3.SJ) > 0) {
t3.aa <- rbind(t3.annot[,c("structural_category", "perc", "Var")], t3.a.SJ[,c(1,5,6)])

for(i in 1:length(t3.list)){
set=data.frame(t3.data.sets[i])
c=data.frame(t3.list[i])
if (!all(is.na(set))){
t.temp=t3.aa
t3.aa = rbind(t.temp, c[,c(1,5,6)])
}
}

p28.a <- ggplot(data=t3.aa, aes(x=structural_category, y=perc, fill= Var)) +
geom_bar(position = position_dodge(), stat="identity", width = 0.7, size=0.3, color="black") +
guides(fill=guide_legend(nrow=2,byrow=TRUE)) +
scale_fill_manual(values = c(myPalette)) +
scale_y_continuous(expand = expansion(mult = c(0,0.1))) +
ylab("Transcripts, %") +
xlab("") +
mytheme +
theme(legend.position="bottom", axis.title.x = element_blank()) +
ggtitle( "Good Quality Control Attributes Across Structural Categories\n\n" ) +
theme(axis.text.y = element_text(size=10),
axis.text.x = element_text(size=10))+
theme(legend.title = element_blank())
}

p28.a <- ggplot(data=t3.aa, aes(x=structural_category, y=perc, fill= Var)) +
geom_bar(position = position_dodge(), stat="identity", width = 0.7, size=0.3, color="black") +
guides(fill=guide_legend(nrow=2,byrow=TRUE)) +
scale_fill_manual(values = c(myPalette)) +
scale_y_continuous(expand = expansion(mult = c(0,0.1))) +
ylab("Transcripts, %") +
xlab("") +
mytheme +
theme(legend.position="bottom", axis.title.x = element_blank()) +
ggtitle( "Good Quality Control Attributes Across Structural Categories\n\n" ) +
theme(axis.text.y = element_text(size=10),
axis.text.x = element_text(size=10))+
theme(legend.title = element_blank())
}



#TSS ratio
data.ratio = rbind(data.refmatch[,c(6,48)], data.ISM[,c(6,48)])
if (!all(is.na(data.ratio$ratio_TSS))){
Expand Down
2 changes: 1 addition & 1 deletion utilities/report_qc/SQANTI3_report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ ggplotly(p28)%>%
cat ('\n')
```

```{r ,exists("p28.RTS")}
```{r , eval = exists("p28.RTS")}
cat("#### RT-switching {.tabset .tabset-fade }")
ggplotly(p28.RTS)%>%
layout(margin = list(r = 130)) %>%
Expand Down
35 changes: 22 additions & 13 deletions utilities/report_qc/generatePDFreport.R
Original file line number Diff line number Diff line change
Expand Up @@ -501,35 +501,43 @@ generatePDFreport = function()

s <- textGrob("Features of Bad Quality", gp=gpar(fontface="italic", fontsize=17), vjust = 0)
grid.arrange(s)
print(p28.RTS)
print(p28.SJ)
if (n_t3.SJ>0 & n_t3.RTS>0 & !all(is.na(data.class$min_cov))) {
print(p28.Cov)
if (exists("p28.RTS")){
print(p28.RTS)
}
if (n_t3.SJ>0 & n_t3.RTS>0 &!all(is.na(data.class$predicted_NMD))) {
print(p28.NMD)
}
if (n_t3.SJ>0 & n_t3.RTS>0) {
print(p28)
if (exists("p28.SJ")){
print(p28.SJ)
}

if(exists("n_t3.SJ") & exists("n_t3.RTS")){
if (n_t3.SJ>0 & n_t3.RTS>0 & !all(is.na(data.class$min_cov))) {
print(p28.Cov)
}
if (n_t3.SJ>0 & n_t3.RTS>0 &!all(is.na(data.class$predicted_NMD))) {
print(p28.NMD)
}
if (n_t3.SJ>0 & n_t3.RTS>0) {
print(p28)
}
}
s <- textGrob("Features of Good Quality", gp=gpar(fontface="italic", fontsize=17), vjust = 0)
grid.arrange(s)
if (!all(is.na(data.class$dist_to_cage_peak))) {
print(p28.a.Cage)
}
print(p28.a.annot)
if(exists("p28.a.annot")){
print(p28.a.annot)
}

if (!all(is.na(data.class$polyA_motif))) {
if (!all(is.na(data.class$polyA_motif)) && exists("p28.a.polyA")) {
print(p28.a.polyA)
}
print(p28.a.SJ)
if(exists("p28.a.SJ")){print(p28.a.SJ)}

if (!all(is.na(data.class$min_cov)) && exists("p28.a.Cov")) {
print(p28.a.Cov)
}

if (nrow(t3.SJ) > 0) {
if (exists("t3.SJ") && nrow(t3.SJ) > 0) {
print(p28.a)
}

Expand All @@ -541,3 +549,4 @@ generatePDFreport = function()

print("SQANTI3 report successfully generated!")
}

0 comments on commit 43070e3

Please sign in to comment.