Creating a correlation matrix with R

Updated 2024 April 7th Incentive Let be a matrix, where are elements of , where is the row and is the column. If the matrix contained transcript expression data, then is the expression level of the transcript in the assay. The elements of the row of form the transcriptional response of the transcript. The elements…

Continue Reading

Processing rows of a data frame in R

Once you’ve read in a tab delimited file into a data.frame, here’s one way of operating on the rows I’m still wondering why I need two conversion steps ( e.g. var(as.vector(as.matrix(data_subset[1,]))) ), since var(as.vector(data_subset[1,])) doesn’t work. In time, when I learn more about data.frames and R in general I hope to address this or if…

Continue Reading

Using bins when comparing genomic features

Comparing two files containing genomic features is a common task e.g. finding out whether the coordinates of your tags intersect with genes. Of course you could use intersectBed (as part of the BEDTools suite) for this purpose but here’s how to do it anyway using Perl. NOTE: I hard code the length of my tags…

Continue Reading

Forking in Perl 2

Build up an index of files to process, e.g. SAM files. Fork out 16 child processes, each time processing and eliminating one file from the index. As with all my code, use at your own risk. Comments and suggestions always welcome. For more information see Forking in Perl.

Continue Reading

Using Perl to log transform data

Very simple code using Perl to log transform (base 2) a list of numbers. 0 values are converted into 0.5, since you cannot take the logarithm of 0. For this example numbers are stored in the array @n. Using R I know this post is about using Perl to log transform data, but I’ve been…

Continue Reading

Perl and SAM

Lincoln Stein has written a bunch of modules to deal with SAM/BAM files. Check out the CPAN module. If you are having trouble installing Bio::DB::Sam, you may have to recompile SAMTools with the following command: To install the Perl module on a machine where you don’t have root access, follow these instructions. Using this module,…

Continue Reading

Forking in Perl

Foreach item in the array, start a fork. $pid returns 0 if it is the child process. This way you can spawn 4 child processes from one parent. This page explains it all and the code shown below is an adaptation of code shown from the link. I just added code to show the current…

Continue Reading