Blog Archives

Using R: a function that adds multiple ggplot2 layers

April 23, 2017
By
Using R: a function that adds multiple ggplot2 layers

Another interesting thing that an R course participant identified: Sometimes one wants to make a function that returns multiple layers to be added to a ggplot2 plot. One could think that just adding them and returning would work, but it doesn’t. I think it has to do with how + is evaluated. There are a

Read more »

Using R: Don’t save your workspace

April 2, 2017
By
Using R: Don’t save your workspace

To everyone learning R: Don’t save your workspace. When you exit an R session, you’re faced with the question of whether or not to save your workspace. You should almost never answer yes. Saving your workspace creates an image of your current variables and functions, and saves them to a file called ”.RData”. When you

Read more »

It seems dplyr is overtaking correlation heatmaps

March 8, 2017
By
It seems dplyr is overtaking correlation heatmaps

(… on my blog, that is.) For a long time, my correlation heatmap with ggplot2 was the most viewed post on this blog. It still leads the overall top list, but by far the most searched and visited post nowadays is this one about dplyr (followed by it’s sibling about plyr). I fully support this,

Read more »

Using R: tibbles and the t.test function

February 12, 2017
By
Using R: tibbles and the t.test function

A participant in the R course I’m teaching showed me a case where a tbl_df (the new flavour of data frame provided by the tibble package; standard in new RStudio versions) interacts badly with the t.test function. I had not seen this happen before. The reason is this: Interacting with legacy code A handful of

Read more »

Balancing a centrifuge

June 11, 2016
By
Balancing a centrifuge

I saw this cute little paper on arxiv about balancing a centrifuge: Peil & Hauryliuk (2010) A new spin on spinning your samples: balancing rotors in a non-trivial manner. Let us have a look at the maths of balancing a centrifuge. The way I think most people (including myself) balance their samples is to put

Read more »

Toying with models: The Game of Life with selection

February 29, 2016
By
Toying with models: The Game of Life with selection

Conway’s Game of life is probably the most famous cellular automaton, consisting of a grid of cells developing according simple rules. Today, we’re going to add mutation and selection to the game, and see let patterns evolve. The fate of a cell depends on the number cells that live in the of neighbouring positions. A

Read more »

Toying with models: The Luria–Delbrück fluctuation test

February 19, 2016
By
Toying with models: The Luria–Delbrück fluctuation test

I hope that Genetics will continue running expository papers about their old classics, like this one by Philip Meneely about Luria & Delbrück (1943). Luria & Delbrück performed an experiment on bacteriophage resistance in Escherichia coli, growing bacterial cultures, exposing … Läs mer →

Read more »

R in genomics @ SciLifeLab, Solna

March 24, 2015
By
R in genomics @ SciLifeLab, Solna

Dear diary, I went to the Stockholm R useR group meetup on R in genomics at the Stockholm node of SciLifeLab. It was nice. If I had worked a bit closer I would attend meetups all the time. I even got to be pretentious with my notebook while waiting for the train. The speakers were:

Read more »

Finding the distance from ChIP signals to genes

July 4, 2014
By
Finding the distance from ChIP signals to genes

I’ve had a couple of months off from blogging. Time for some computer-assisted biology! Robert Griffin asks on Stack Exchange about finding the distance between HP1 binding sites and genes in Drosophila melanogaster.  We can get a rough idea with some public chromatin immunoprecipitation data, R and the wonderful BEDTools. Finding some binding sites There

Read more »

More fun with %.% and %>%

March 27, 2014
By
More fun with %.% and %>%

The %.% operator in dplyr allows one to put functions together without lots of nested parentheses. The flanking percent signs are R’s way of denoting infix operators; you might have used %in% which corresponds to the match function or %*% which is matrix multiplication. The %.% operator is also called chain, and what it does

Read more »

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)