omarwagih / ggseqlogo

Publication-quality sequence logos in R
208 stars 30 forks source link

RNA seq logo #37

Open XqKang opened 10 months ago

XqKang commented 10 months ago

Hi I want to plot my RNA sequence logoI am running following code:

Trub1_sig <- read.csv("C:/Users/kang.xin/Rouhanifard lab Dropbox/Keqing/hypermod_fish/Sequecing/sig_psi_sites_Trub1.csv",header = T) Trub1_sig$kmer_fixed <- gsub("T", "U", Trub1_sig$kmer_Scramble) trub1_motif <- Trub1_sig$kmer_fixed

Determine the length of your sequences (assuming they are all the same length)

trub1_sequence_length <- nchar(trub1_motif[1])

Create an empty PFM with rows named after nucleotides (A, C, G, T)

trub1pfm <- matrix(0, nrow = 4, ncol = trub1_sequence_length, dimnames = list(c("A", "C", "G", "U"), NULL))

Populate the PFM with nucleotide frequencies

for (i in 1:length(trub1_motif)) { for (j in 1:trub1_sequence_length) { nucleotide <- substr(trub1_motif[i], j, j) trub1pfm[nucleotide, j] <- trub1pfm[nucleotide, j] + 1 } }

Create the sequence logo

Trub1_seqlogo <- ggseqlogo::ggseqlogo(trub1pfm) Trub1_seqlogo + scale_x_continuous(breaks = seq(1, nchar(trub1_motif[1]), 1)) + scale_fill_manual(values = c("A" = "green", "C" = "blue", "G" = "orange", "U" = "red")) + theme_minimal() + labs(title = "Trub1 Motif Sequence Logo") ggsave(filename = "C:/Users/kang.xin/Rouhanifard lab Dropbox/Keqing/hypermod_fish/Sequecing/Trub1_seqlogo.svg", plot = Trub1_seqlogo, device = "svg") dev.off()

But it seems like it keep plotting T instead of U? sig_psi_sites_Trub1.csv

sessionInfo() R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C LC_TIME=English_United States.utf8

time zone: America/New_York tzcode source: internal

attached base packages: [1] stats4 grid stats graphics grDevices utils datasets methods base

other attached packages: [1] reshape2_1.4.4 Biostrings_2.68.1 GenomeInfoDb_1.38.5 XVector_0.42.0 IRanges_2.36.0 S4Vectors_0.40.2 BiocGenerics_0.48.1 [8] tidyr_1.3.1 dplyr_1.1.4 seqLogo_1.68.0 ggseqlogo_0.1.0 ggplot2_3.4.4

loaded via a namespace (and not attached): [1] gtable_0.3.4 crayon_1.5.2 compiler_4.3.0 BiocManager_1.30.22 Rcpp_1.0.12 tidyselect_1.2.0
[7] stringr_1.5.1 bitops_1.0-7 scales_1.3.0 plyr_1.8.9 R6_2.5.1 labeling_0.4.3
[13] generics_0.1.3 tibble_3.2.1 munsell_0.5.0 GenomeInfoDbData_1.2.11 pillar_1.9.0 rlang_1.1.3
[19] utf8_1.2.4 stringi_1.8.3 cli_3.6.2 withr_3.0.0 magrittr_2.0.3 zlibbioc_1.48.0
[25] rstudioapi_0.15.0 lifecycle_1.0.4 vctrs_0.6.5 glue_1.7.0 farver_2.1.1 RCurl_1.98-1.14
[31] fansi_1.0.6 colorspace_2.1-0 purrr_1.0.2 tools_4.3.0 pkgconfig_2.0.3