Skip to content

Commit 0a9a307

Browse files
committed
gap removal added
1 parent ecfefe7 commit 0a9a307

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

R/community_motif.R

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,20 @@ get_motif <- function(chain, node_summary, gap_remove_prob) {
3333
}
3434
}
3535

36+
# remove gaps if they exceed specific threshold on position
3637
aln <- msa::msaClustalOmega(inputSeqs = AAStringSet(cdrs), type = "protein")
37-
g <- ggseqlogo(as.character(aln), seq_type='aa', method = "probability")+
38+
aln <- as.character(aln)
39+
alnm <- do.call(rbind, strsplit(aln, split = ""))
40+
gap_rm <- apply(X = alnm, MARGIN = 2, gap = gap_remove_prob,
41+
FUN = function(x, gap) {
42+
return(sum(x=="-")/length(x) >= gap)
43+
})
44+
if(any(gap_rm)) {
45+
alnm <- alnm[, which(gap_rm), drop = FALSE]
46+
}
47+
aln <- apply(alnm, 1, paste0, collapse = "")
48+
49+
g <- ggseqlogo(aln, seq_type = 'aa', method = "probability")+
3850
theme_logo(base_size = 10)+
3951
theme(legend.position = "none")+
4052
scale_y_continuous(breaks = c(0, 0.5, 1), labels = c(0, 0.5, 1))

0 commit comments

Comments
 (0)