Skip to main content

Week 12: Creating an R Markdown File for Alignment Score Visualization

 Week 12:  Creating an R Markdown File for Alignment Score Visualization



Creating the R Markdown file "Alignment Score Visualization" was a great learning experience. It allowed me to combine R code, text, and visuals in one document, which is both easy to read and share. Here’s what I learned and how it went:

Getting Started

At first, R Markdown felt a bit confusing because it combines text and code in one file. But once I understood the structure, it became clear how powerful it is. The key was using code chunks, which are sections of the file that run the R code. Each chunk starts with ```{r} and ends with ```.

For my project, I wanted to display alignment scores for V and J regions in a table and a bar chart. Writing and organizing the code into chunks made it easy to run and test each part.

Challenges I Faced

  1. Code Showing as Plain Text:
    When I first tried knitting the file, the HTML output only showed the code as plain text. I realized this was because I had included everything in the setup chunk, which is only for settings. Separating the data and visualization code into their own chunks fixed this.





  1. Troubleshooting Errors:
    Debugging code in R Markdown was tricky because knitting stops when there’s an error. To fix this, I ran each chunk one by one in RStudio before knitting the whole file. This made it easier to find and fix mistakes.

  2. Deciding What to Show:
    I learned that I could control whether the code or just the results showed up in the final document. For the table, I wanted both the code and output to show, so I used echo = TRUE. For the bar chart, I hid the code (echo = FALSE) so the focus was on the visualization.


What I Learned

  • R Markdown Is Powerful:
    It’s a great tool for combining text, code, and results in one document. It makes it easy to share your work in a clear and professional way.

  • The Importance of Code Chunks:
    Properly setting up code chunks is key. Using options like echo, eval, and include helped me decide what to show in the final file.

  • Data Visualization with ggplot2:
    Creating the bar chart with ggplot2 was simple and fun. I learned how to make clear, customizable visualizations that look professional.


Reflection

I’m pretty happy with how this project turned out. It showed me how useful R Markdown is for combining analysis, text, and visuals. In the future, I plan to use R Markdown for more projects, try new output formats like PDF, and even add interactive visualizations.

If you’re new to R Markdown, I recommend starting with a small project like this. It’s a great way to learn how to present your work effectively.


For a more detailed exploration visit my GitHub repository


Comments

Popular posts from this blog

DNA Sequence Alignment and Visualization with "SequenceAlignment" Package

 DNA Sequence Alignment and Visualization with "SequenceAlignment" Package In bioinformatics, sequence alignment plays a crucial role in comparing biological sequences, especially DNA sequences. It helps in identifying similarities, differences, and evolutionary relationships between sequences. In this blog, we’ll explore how to use the SequenceAlignment R package for performing sequence alignments, visualizing the results with plots like barplots and heatmaps , and analyzing DNA sequences against multiple reference sequences stored in FASTA files. What is Sequence Alignment? Sequence alignment is the process of comparing two or more biological sequences (e.g., DNA, RNA, or proteins) to identify regions of similarity or difference. In DNA sequence alignment, the sequences are compared to see how closely they match, which can provide insights into genetic similarities, mutations, or evolutionary trends. The SequenceAlignment Package The SequenceAlignment package is a powerf...

Week 8 : Tackling Data Handling Challenges and Finding Solutions

 Week 8 : Tackling Data Handling Challenges and Finding Solutions This time i had the opportunity to dive deeper into R by using the plyr package to compute the mean of grades split by gender and export the results to a file. The task seemed straightforward: import a dataset, perform some basic operations, and output the result. However, as with most programming journeys, I encountered a few hurdles along the way, leading to a wealth of learning. Step 1: Importing the Dataset The first task was to import a dataset into R. I used the read.table() function, which reads the file in a tabular format. Initially, the command worked well, but I did face a minor challenge when choosing the right separator for the CSV file ( sep="," ). This was an easy fix once I realized the file used commas to separate values. Here's the command that worked: Lesson learned: Always double-check the file format and ensure the separator used in the file is correctly specified. Step 2: Calculatin...

Journey Through R Programming: Week 1

  Journey Through R Programming: Week 1 Introduction Welcome to my blog! As part of my Open Source R course with Professor Alon Friedman at the University of South Florida, I’m excited to document my weekly progress in learning R programming. A bit about me: I’m currently pursuing a Master’s in Bioinformatics & Computational Biology, following an undergrad in Biotechnology. My programming journey began with Python through the “100 Days of Code: The Complete Python Pro Bootcamp” on Udemy, which included around 8 mini projects. This experience has made transitioning to R a bit smoother, as many concepts overlap. To support my learning, I’m using the book  The Art of R Programming  and the edX course  Data Science: R Basics  from Harvard University. These resources have been invaluable in deepening my understanding of R. Summary 1. Function Creation Objective: Create a function to count the number of odd numbers in a vector. Code: What I Learned: The modulus op...