2012-12-28

Functions dim, nrow, and ncol for shell

Ever wanted to find out quickly the number of rows and/or columns in file directly from terminal. There are many ways to skin this cat. Here is what I used for number of rows for quite a while:

wc -l filename

What about number of columns? "Easy", just combine head and awk commands:

head -n 1 filename | awk '{ print NF }'

not a big problem (there are likely better ways to do this), but is long and tedious.

I got sick of typing commands above and assembled them in three easy to use function with R-like names: nrow, ncol, and dim. Functions are simply a collection of above ideas and assume that the file is of "rectangular shape", i.e., a table, a matrix, etc.


dim()
{
  for FILE in $@; do
    NROW=$(nrow $FILE | awk '{ print $1}')
    NCOL=$(ncol $FILE | awk '{ print $1}')
    echo "$NROW $NCOL $FILE"
    unset NROW NCOL
  done
}
export -f dim

nrow ()
{
  for FILE in $@; do
    wc -l $FILE
  done
}
export -f nrow

ncol ()
{
  for FILE in $@; do
    TMP=$(head $FILE -n 1 | awk '{ print NF }')
    echo "$TMP $FILE"
    unset TMP
  done
}
export -f ncol

Add these files to your .bashrc or .profile or something similar and you can now simply type:

nrow filename
ncol filename
dim filename

A simple test:

touch file.txt
echo "line1 with four columns" >> file.txt
echo "line2 with four columns" >> file.txt

nrow file.txt
2 file.txt

ncol file.txt
4 file.txt

dim file.txt
2 4 file.txt

2012-12-04

Recover deleted file under linux

Here is a nice summary, but the bottom line is that the Ubuntu/Debian package testdisk has a nice utility called photorec that can be used to search for deleted files and recover. This is not a GUI program, though!

2012-09-30

Whole-genome evaluation of complex traits using SNP, haplotype, or QTL information

This is the presentation (and abstract bellow) of my talk at local congress Genetika 2012.
Whole-genome evaluation of complex traits using SNP, haplotype, or QTL information

Abstract:

Whole-genome technologies provide rich data for dissection of complex traits. While gene discovery is still largely limited, the data at hand can be successfully used for evaluation of genetic merit. The aim of this work was to demonstrate the value of different sources of information (pedigrees, Single Nucleotide Polymorphisms – SNP, haplotypes, or Quantitative Trait Loci – QTL) for genetic evaluation of non-phenotyped individuals in a typical animal breeding scenario via simulation. In the first step a coalescent simulation was used to create a base population with structured chromosomes that were in the second step dropped and recombined through the pedigree of 10 generations with 50 sires per generation, 10 dams per sire, and 2 offspring per dam. Phenotypic values were simulated with different genetic architectures (QTL effects were sampled from Gaussian or gamma distribution and minor allele frequency less than 0.3) and heritability of 0.25. Genotypic data was available for all individuals from generation 4 onwards, while phenotypic data was available for individuals in generations 4 and 5. Genetic evaluation was based on linear mixed models with relationship matrix between individuals. This matrix was built using pedigree, SNP, haplotype, or QTL data. Haplotypes of different length were considered (from 5 to all the way up to 2000 SNP) with an option to account for similarities between haplotypes while building relationship matrices. The accuracy of different methods was assessed by correlation between true and evaluated additive genetic values for individuals in generations 6, 8 and 10. Average accuracy over ten replications for Gaussian trait over generations was between 0.45 to 0.10 for pedigree data, 0.50 to 0.35 for SNP and haplotype data and 0.6 to 0.4 for QTL data. In the case of long haplotypes accuracies dropped considerably, but accounting for similarities between haplotypes prevented this drop. In the case of gamma trait accuracies were slightly higher in generation 6 and dropped faster in the later generations in the case of pedigree, SNP, and haplotype data due to recombinations. On the other hand accuracies were substantially higher with QTL data and quite stable over generations (from 0.75 to 0.65) though still far from perfect (even though QTL genotypes are known), due to estimation errors. Results demonstrate the value and limitations of genotypic information for the evaluation of additive genetic merit in animal populations.

2012-09-29

Software Tools for Animal Gene Mapping

Here are some cool tools for animal genetics:

  • AGDP for the analysis of genome differences between opulations
  • SNPEVG graphical tool for SNP effect viewing and graphing
  • ...



2012-09-23

Google drive drives in

I just realized that Google offers me "Google drive". The pricing options for larger disk space than 5GB are very competitive with Dropbox! I am using Dropbox for all my files - yes, it costs me quite some money when the bill comes, but if we consider this is "few" dollars per month for backup and synchronization I am more than willing to pay this amount for this!!! Google drives is now yet another option, but the desktop folder does not work on Linux so for now I will stick with Dropbox.

2012-08-11

“Livestock Conservation Genomics: Data, Tools and Trends“ Summer School, Croatia, Oct 1-7, 2012

There will be an ESF GENOMIC-RESOURCES (link1, link2) summer school “Livestock Conservation Genomics: Data, Tools and Trends“ Summer School, Croatia, Oct 1-7, 2012. You can find more details here.

2012-08-09

Nice SNP tools from the Pevsner laboratory

SNPduo - compare SNPs from two individuals
SNPtrio - compare SNPs from a family trio - very cool plots and nice diagnostics
kcoeff - estimate K0, K1, and K2 coefficients from SNP data