Blog Archives

Summarize content of a vector or data.frame every n entries

August 8, 2013
By
Summarize content of a vector or data.frame every n entries

I imagine that the same result can be achieved by a proper use of quantile, but I like to have an easy way to obtain summary statistics every n entries of my dataset be it a vector or data.frame. The function takes three parameters: the R object on which we need to obtain statistics (x),

Read more »

R and theater

June 3, 2012
By
R and theater

You might ask what R has to do with theater. I assure you it has. I act in the theater group ‘ndescenze. We will soon present (actually, we just performed) a show based on the Marx Brothers Radio Shows. We shuffle actors and characters during the show (we like it complicated!) and we needed to

Read more »

Introduction to R

May 25, 2012
By
Introduction to R

I am happy to repost the information I got about the course “Introduction to R” that will be organized by Milano R net in collaboration with Quantide. The course will be held in Milano, Italy, June 7-8, 2012, and is intended to introduce the unexperienced user to R. For furhter info visit milano R net

Read more »

Milano R net meeting

April 24, 2012
By
Milano R net meeting

I received the announce of the first Milano R net meeting, and I am glad to post it below. If you are based in Milano area you might think about going. If you are not based in Milano area, you might think about going as well! Milano R net Milano R net is a users

Read more »

Extract different characters between two strings of equal length

January 3, 2012
By
Extract different characters between two strings of equal length

In the desperate effort of understanding the secret of life it may be too simplistic to just count the differences between two strings of equal length. You might as well want to know where they differ. You can do that recycling most of the function published in a previous post. You can use it to

Read more »

Count different positions between two strings of equal length

November 26, 2011
By
Count different positions between two strings of equal length

This is another pretty simple function, written to help me solve the simplest representation of a trivial but tedious task. Most biologist are probably familiar with this task. How many nucleotide differences exist between two given sequences? I only faced the easiest part of the problem, i.e. I do not perform alignment, I just assume that

Read more »

Estimate decay of linkage disequilibrium with distance

August 9, 2011
By
Estimate decay of linkage disequilibrium with distance

It is well known that linkage disequilibrium (LD) decays with distance. Several functions have been proposed to estimate such decay. Among the most widely used are the Hill and Weir (1) formula for describing the decay of r2 and a formula proposed by Abecasis (2) for describing the decay of D’. I wrote R functions

Read more »

For happy-R blogging

May 3, 2011
By
For happy-R blogging

You may notice that I don’t have that many posts on my blog, and they are all about R. The paucity of my posts makes me a bit sad, but not much, really… What makes (or better, used to make me) sad is that posts of R code (used to) look awful. However, your code

Read more »

Estimate Gene Diversity

May 3, 2011
By
Estimate Gene Diversity

I provide here an R function to estimate gene diversity of diallelic sites (e.g. SNPs), given allele frequencies at each segregating site. The function takes three input parameters: maf: a numeric value (or vector) representing minor allele frequency at each site. Default is 0.5 nreads: size of each resampling experiment. Default is 10000. nreplicates: Number

Read more »

R function to convert degrees to radians

December 23, 2010
By
R function to convert degrees to radians

I would have never imagined that I would have to go back to high school concepts and do strange trigonometric calculations. However, it happened to me that I needed to convert GPS coordinates of a large data set to radians. It’s a trivial task, if you know how to do it. The function takes as

Read more »