<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rafael Bravo on Medium]]></title>
        <description><![CDATA[Stories by Rafael Bravo on Medium]]></description>
        <link>https://medium.com/@rbravos87?source=rss-fa7178563da7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*u3KqEdlWOYde9siS</url>
            <title>Stories by Rafael Bravo on Medium</title>
            <link>https://medium.com/@rbravos87?source=rss-fa7178563da7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:48:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rbravos87/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I Organize My Projects in R (I): The Working Directory]]></title>
            <link>https://towardsdev.com/how-i-organize-my-projects-in-r-i-the-working-directory-b094785b9a11?source=rss-fa7178563da7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b094785b9a11</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Rafael Bravo]]></dc:creator>
            <pubDate>Mon, 16 Feb 2026 03:15:29 GMT</pubDate>
            <atom:updated>2026-02-16T12:12:02.907Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever opened an old R project and thought, <em>“What was I doing here?”</em>, you’re not alone. Disorganized projects quietly drain productivity — especially in academia, where analyses often span months or years.</p><p>Over time, I realized that I didn’t need the perfect project structure. I needed a reliable one. A system that makes new projects easy to start — and old projects easy to understand.</p><p>This is the first post in a short series where I explain exactly how I organize my R projects for reproducibility and clarity.</p><h3>Step 1: Create the Structure Before Writing Any Analysis</h3><p>Before I write a single line of code, I create the entire folder structure.</p><p>Not gradually.<br>Not when I “need it.”<br>Not halfway through the project.</p><p>Immediately.</p><p>Why?</p><p>Because every small decision you postpone later becomes a cognitive load.<br>And cognitive load compounds.</p><p>If the structure already exists, I don’t waste time asking:</p><ul><li>“Where should this file go?”</li><li>“Should I create another folder?”</li><li>“Where did I save that table?”</li></ul><p>The system answers for me.</p><h3>The Script I Use in Every Project</h3><p>This is the exact script I run at the start of every new R project:</p><pre># List of directories to be created<br>directories &lt;- c(&quot;00_raw_data&quot;, <br>                 &quot;01_cleaned_data&quot;, <br>                 &quot;02_environments&quot;, <br>                 &quot;03_scripts&quot;, <br>                 &quot;04_tables&quot;, <br>                 &quot;05_graphs&quot;,<br>                 &quot;06_quarto&quot;)<br><br># Create each directory<br>for(dir in directories){<br>  dir.create(dir)<br>}</pre><p>That’s it.</p><p>Simple.<br>Reusable.<br>Automatic.</p><p>No complexity. Just consistency.</p><h3>What the Structure Looks Like</h3><p>After running the script, my project looks like this:</p><pre>project_name/<br>│<br>├── 00_raw_data/<br>├── 01_cleaned_data/<br>├── 02_environments/<br>├── 03_scripts/<br>├── 04_tables/<br>├── 05_graphs/<br>└── 06_quarto/</pre><p>At a glance, I immediately know:</p><ul><li>Where the original data lives</li><li>Where processed data is stored</li><li>Where analysis scripts go</li><li>Where outputs are generated</li><li>Where reports are built</li></ul><p>There’s no ambiguity.</p><h3>Why I Separate Raw and Cleaned Data</h3><p>This is one of the most important rules in my workflow.</p><p>00_raw_data is untouchable.</p><p>I never edit those files manually. Ever.</p><p>01_cleaned_data contains data that has been transformed through scripts. If something breaks, I can always regenerate it from the raw data.</p><p>This simple separation protects reproducibility — especially in academic projects that may need to be audited, shared, or revisited years later.</p><h3>Why I Number Everything</h3><p>The numbering isn’t aesthetic.</p><p>It’s strategic.</p><p>It:</p><ul><li>Forces logical order</li><li>Keeps the workflow aligned</li><li>Reduces navigation friction</li><li>Makes every project look the same</li></ul><p>My workflow always follows this sequence:</p><p><strong>Raw Data → Cleaned Data → Environments → Scripts → Tables → Graphs → Quarto</strong></p><p>Because folders are numbered, they always appear in this order — in Finder, in RStudio, everywhere.</p><p>No thinking required.</p><h3>The Small Habit That Saves Hours Later</h3><p>This script is always named:</p><p><strong>00_directories.R</strong></p><p>And it always lives inside:</p><p><strong>03_scripts</strong></p><p>I keep a master copy in my main projects folder. When I start a new project, I paste it in and run it once.</p><p>It takes less than 10 seconds. But it prevents hours of future confusion.</p><p>Good organization rarely feels urgent — until you don’t have it.</p><p>The goal isn’t perfection.<br>It’s reducing friction for your future self.</p><p>Six months from now, when you reopen the project, the structure should explain your thinking — without you having to remember it.</p><h3>Room for improvement</h3><p>This system works for me — but it’s not the only way to do it. If you organize your R projects differently, or if you see ways this structure could be improved, I’d love to hear your thoughts. Good workflows evolve, and thoughtful feedback makes them better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b094785b9a11" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/how-i-organize-my-projects-in-r-i-the-working-directory-b094785b9a11">How I Organize My Projects in R (I): The Working Directory</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Pipettes to Programming: My Journey]]></title>
            <link>https://medium.com/@rbravos87/from-pipettes-to-programming-my-journey-c4da12c01037?source=rss-fa7178563da7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4da12c01037</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[bioscience]]></category>
            <category><![CDATA[dry-lab]]></category>
            <category><![CDATA[wet-lab]]></category>
            <category><![CDATA[biostatistics]]></category>
            <dc:creator><![CDATA[Rafael Bravo]]></dc:creator>
            <pubDate>Thu, 24 Jul 2025 17:45:02 GMT</pubDate>
            <atom:updated>2025-07-24T17:45:02.536Z</atom:updated>
            <content:encoded><![CDATA[<p>Everything started during my PhD in Physiology &amp; Immunology, when I worked extensively with rats to study their circadian rhythms — those biological functions that follow a ~24-hour cycle. During that time, I spent a lot of hours processing blood samples, but I also needed a solid foundation in basic biostatistics to analyze the patterns I was observing, especially under obesity conditions.</p><p>Back then, like many in the field, I used GraphPad Prism for most of my statistical analyses. I always found statistics fascinating — while others saw it as boring or intimidating, I enjoyed the logic behind it.</p><p>Eventually, I moved to the U.S. to dive deeper into the molecular aspects of circadian rhythms, focusing on gene expression and protein levels across different mouse tissues. During my first postdoc, I joined a project that involved processing massive datasets — something well beyond the capabilities of Excel, GraphPad, or SPSS. That’s when I turned to R, a tool I hadn’t used before, to handle thousands of data points.</p><p><strong>So how did I start with R? Was it hard?</strong></p><p>That’s a question I get all the time, especially from people curious about my transition from molecular biology to biostatistics.</p><p>Honestly, it wasn’t easy — but it’s definitely doable. There are plenty of free resources that help make the learning curve less steep. I started with a couple of courses focused on data visualization and basic preprocessing in R. Those helped me ease into programming without feeling overwhelmed.</p><p>The hardest part was the beginning — getting used to seeing lots of red error messages and shifting my mindset to think like a programmer. But I kept at it, following tutorials and looking up similar problems on sites like StackOverflow. After a few months, I was generating graphs and processing data with confidence — and realizing just how powerful a tool R had become for me.</p><p>One of the best parts? Reproducibility. With code, I could easily replicate my analyses and track everything in a script. No more trying to remember exactly what steps I followed in Excel. Sure, I spent a lot of time learning, but it paid off — now I can generate publication-ready figures in minutes.</p><p>Eventually, I got curious about Python. Nobody asked me to learn it — I just wanted to explore another tool. I began doing in Python what I had been doing in R, using Jupyter Notebooks to practice and learn on my own terms.</p><p>At the same time, my research in circadian biology often meant working night shifts to collect samples. And during that period, I also became a dad to two wonderful kids. I realized the wet lab lifestyle wasn’t compatible with the kind of family life I wanted. But where could I go from there? Academia still felt uncertain, and I wasn’t ready for a leap into industry without better training.</p><p>So, I made a strategic move. I took another postdoc position at my university — this time in biostatistics.</p><p><strong>Yes, as a trainee, you <em>can</em> pivot.</strong></p><p>This new postdoc allowed me to build on my coding skills and learn new statistical methods, while still leveraging my background in molecular biology and circadian rhythms. It was a perfect blend of old and new, and it gave me a clearer vision of where my career could go.</p><p>Today, at the end of my postdoc training, I’m still publishing research on circadian rhythms — but now I’ve also built strong computational skills. I work in a hybrid setup that lets me balance science and family life. Do I miss the bench and my pipettes? Absolutely — especially after mastering some techniques. But I don’t miss the late nights troubleshooting failed experiments, rushing to daycare pickups, or weekends spent in the lab.</p><p><strong>Now, I’m simply happier.</strong><br> Working in a dry lab has given me flexibility, peace of mind, and a backup plan: I’ve positioned myself to work as a bioinformatician or data scientist if I ever need to make a move out of academia into something more stable or better paid.</p><p>And that’s the beauty of it — science doesn’t have to follow just one path.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4da12c01037" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data visualization — Dot plots, mean and standard error in R (Part II)]]></title>
            <link>https://towardsdev.com/data-visualization-dot-plots-mean-and-standard-error-in-r-part-ii-aa1a99222ddc?source=rss-fa7178563da7------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa1a99222ddc</guid>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Rafael Bravo]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 01:20:06 GMT</pubDate>
            <atom:updated>2023-01-18T13:35:27.212Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data visualization — Dot plots, mean and standard error in R (Part II)</h3><p>In the previous <a href="https://medium.com/@rbravos87/data-visualization-dot-plots-mean-and-standard-error-in-r-part-i-f1e7bdd3fed4">post</a> I explained how to plot a graph with dot plots, mean and Standard Error of the Mean (SEM). However, it is possible to take a step forward.</p><p>Iris dataset contains 4 different types of measure for three different plant species. Then, we could plot the four properties in four different graphs… but, it will be way better to plot all the graphs together with only one piece of code. Plotting everything together, in a single graph, will be a much better way to understand the full picture.</p><p>Let´s do it! But first, we will take a look to our data:</p><pre># Load Iris dataset<br>library(datasets)<br>data(iris)<br><br>#Check dataset<br>head(iris)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*I0L8Jyxq4CI81C9gjZA_LQ.jpeg" /></figure><p>Personally, I prefer to have the categorical variables before the numerical ones.</p><pre>#Reorder columns (not necessary)<br>iris &lt;- iris %&gt;% relocate(Species)<br>head(iris)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*X4DafxLM18VyH_0siD8Nsg.jpeg" /></figure><p>Now, I will prepare a vector with more appropriate names for the figure, and that vector will be the new column names.</p><pre>#Rename columns<br>ColNames &lt;- c( &quot;Species&quot;, &quot;Sepal length&quot;, &quot;Sepal width&quot;, &quot;Petal length&quot;, &quot;Petal width&quot; )<br>colnames(iris) &lt;- ColNames<br><br>head(iris)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*aUtnz_KPNI0aKqRNbho2sA.jpeg" /></figure><p>Now, we have 4 columns with the variables we want to plot. A first thought would be to perform a loop to iterate over the columns… However, this is a very inefficient process (from a computational perspective) and there are better ways to do it.</p><p>Tidyr has a very interesting option. The function pivot_longer() allows to group different variables into a new one. As a consequence, the result will be a longer dataset. In this way, I will group the four variables into a new one called “Measure”, and the values, into a new variable called “Cm” (centimeters).</p><pre>library(tidyr)<br>iris &lt;- iris %&gt;% pivot_longer(cols=c(&#39;Sepal length&#39;, &#39;Sepal width&#39;, &#39;Petal length&#39;, &#39;Petal width&#39;), <br>             names_to = &quot;Measure&quot; , <br>             values_to = &quot;Cm&quot;)<br><br>head(iris)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*cmzxgs7xnEmsKuqnE6a1pQ.jpeg" /></figure><p>Once we have our data in the longer format, we can plot our graph with the piece of code I used in my <a href="https://medium.com/@rbravos87/data-visualization-dot-plots-mean-and-standard-error-in-r-part-i-f1e7bdd3fed4">last post</a>. Additionally, I will add the option ‘facet_grid()’, which will allow to represent the different subvariables we have inside the variable ‘Measure’</p><pre>library(ggplot2)<br>ggplot(iris, aes(x = Species, y = Cm)) +<br>  stat_summary(geom = &quot;bar&quot;, fun = &quot;mean&quot;, #Bar will represent the mean<br>               aes(), color =&quot;black&quot;, fill = &quot;white&quot;, <br>               width = .9) +<br>  geom_jitter() + #points will be better represented in our graphs<br>  stat_summary(fun.data = mean_se, geom = &quot;errorbar&quot;, color = &quot;red&quot;, width = .15) + #to highlight SEM with many observations<br>  scale_y_continuous(name=&quot;Centimeters&quot;, limits=c(0, 8)) +<br>  ggtitle(&quot;Iris measures&quot;) +<br>  facet_grid(~ Measure) + #to group the graphs by the different mesures<br>  theme_classic()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*rf0OiBTLF897Mqhd9R6Rew.jpeg" /></figure><p>We can see that in only one graph we can plot everything in our dataset with a very efficient code. Finally, we can conclude that there is similar trend in petal length, petal width and sepal length through the considered species. However, sepal width does not show the same trend.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa1a99222ddc" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/data-visualization-dot-plots-mean-and-standard-error-in-r-part-ii-aa1a99222ddc">Data visualization — Dot plots, mean and standard error in R (Part II)</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data visualization — Dot plots, mean and standard error in R (Part I)]]></title>
            <link>https://towardsdev.com/data-visualization-dot-plots-mean-and-standard-error-in-r-part-i-f1e7bdd3fed4?source=rss-fa7178563da7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1e7bdd3fed4</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Rafael Bravo]]></dc:creator>
            <pubDate>Tue, 03 Jan 2023 02:15:01 GMT</pubDate>
            <atom:updated>2023-01-19T12:38:11.621Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data visualization — Dot plots, mean and standard error in R (Part I)</h3><p>Very often, data are expressed as mean and standard error of the mean (SEM). But also, when dealing with biological data, there is an increasing trend to show the dot plot in order to portrait better information about the sample we worked with. Specially, in scientific journals these plots are really appreciated.</p><p>So, the question is, how to plot my data that way? Luckily, R and the package ‘ggplot2’ give us several possibilities to approach this situation. In this post, I will focus specifically in plotting bars, SEM and the individual plots. This kind of graphs will portrait very clearly, for any reader, the information in our data.</p><p>For this example I used the Iris dataset, which contains information about 3 plant species. Each observation contains 2 measures for sepals (length and width) and 2 measures for petals.</p><p><strong>Prepare dataset and check first rows</strong></p><pre># Load Iris dataset<br>library(datasets)<br>data(iris)<br><br># Check dataset<br>head(iris)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*I0L8Jyxq4CI81C9gjZA_LQ.jpeg" /></figure><p>Additionally, for didactic purposes I will work with two datasets in this post: a first dataset with only a few data, and a second one that will contain all the observations.</p><p><strong>Generate the small dataset</strong></p><pre>library(dplyr) <br>iris_s &lt;- iris %&gt;% slice_sample(n = 20) # small subsample with 20 observations<br>print(iris_s)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*DOL-fdxWn0cmKtxK34zWpQ.jpeg" /></figure><p><strong>Visualize data</strong></p><p>Now, we are ready to make some graphs to see how our data are:</p><pre>library(ggplot2)<br>ggplot(iris_s, aes(x = Species, y = Petal.Length)) +<br>  stat_summary(geom = &quot;bar&quot;, fun = &quot;mean&quot;, #Bar will represent the mean<br>               aes(), color =&quot;black&quot;, fill = &quot;white&quot;, <br>               width = .9) +<br>  geom_point() + #to show the dots <br>  stat_summary(fun.data = mean_se, geom = &quot;errorbar&quot;, width = .15) + # mean_se to plot SEM<br>  scale_y_continuous(name=&quot;Length (cm)&quot;, limits=c(0, 6)) +<br>  ggtitle(&quot;Petals length&quot;) +<br>  theme_classic()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*fl51FPIduwpdYjvvyvoqWg.png" /></figure><p>Here we have the result! We can see the mean values for the petals length differ across the species in our small dataset. Also we can have an idea about how data is distributed in our sample.</p><p>This kind of graphs are really useful in wet lab research. When usually you only have a few replicates to compare.</p><p>However… what will happen if we generate the same plot for the whole Iris dataset?? Let´s check it out!</p><pre>library(ggplot2)<br>ggplot(iris, aes(x = Species, y = Petal.Length)) +<br>  stat_summary(geom = &quot;bar&quot;, fun = &quot;mean&quot;,<br>               aes(), color =&quot;black&quot;, fill = &quot;white&quot;, <br>               width = .9) +<br>  geom_point() + #to show the dots <br>  stat_summary(fun.data = mean_se, geom = &quot;errorbar&quot;, width = .15) +<br>  scale_y_continuous(name=&quot;Length (cm)&quot;, limits=c(0, 8)) +<br>  ggtitle(&quot;Petals length&quot;) +<br>  theme_classic()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*XZiehUiEC28Wtp8clCeq7w.png" /></figure><p>Iris dataset contains 150 observations: 50 observations for each specie. In this graph we cannot see every single data because many dots are overlapping… so, it is really complicated to obtain more visual information from our sample.</p><p>Let´s improve it! To get it we will use geom_jitter() instead of geom_point(). Additionally, we will highlight the error bars with red color.</p><pre>ggplot(iris, aes(x = Species, y = Petal.Length)) +<br>  stat_summary(geom = &quot;bar&quot;, fun = &quot;mean&quot;, <br>               aes(), color =&quot;black&quot;, fill = &quot;white&quot;, <br>               width = .9) +<br>  geom_jitter() + <br>  stat_summary(fun.data = mean_se, geom = &quot;errorbar&quot;, color = &quot;red&quot;, width = .15) + #to highlight SEM with many observations<br>  scale_y_continuous(name=&quot;Length (cm)&quot;, limits=c(0, 8)) +<br>  ggtitle(&quot;Petals length&quot;) +<br>  theme_classic()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*chwwzrAnqYIbVUGV2OjHWg.png" /></figure><p>These graphs are simple and elegant, but even you can use them for non-scientific and scientific dissemination.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1e7bdd3fed4" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/data-visualization-dot-plots-mean-and-standard-error-in-r-part-i-f1e7bdd3fed4">Data visualization — Dot plots, mean and standard error in R (Part I)</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>