Wednesday, August 27, 2014

my linux cheat sheet


in random order

chown -R haky:imlab folder_name/

Friday, July 11, 2014

Adding letter head to latex file


\documentclass{article}
\usepackage{wallpaper}
\ULCornerWallPaper{1}{letterheadfile.pdf}
\begin{document}
  Your text on the letterhead
\end{document}

via http://tex.stackexchange.com/questions/837/pdf-letterhead-as-document-background

Tuesday, July 1, 2014

R script to query UCSC database - RMySQL



## this will let you install R packages in a directory where you have access
.libPaths('~/Rlibs/') ## create directory ~/Rlibs if it doesnt exist
install.packages(RMySQL)

## call the RMySQL library
library(RMySQL) 

## connect to UCSC server
channel = dbConnect(MySQL(), user="genome", host="genome-mysql.cse.ucsc.edu")

## for a list of tables check url below
## http://hgdownload.cse.ucsc.edu/goldenPath/hg19/database/

## convenience function to run SQL queries
query <- function(...) dbGetQuery(channel, ...)

## use hg19 database in UCSC to use
query("USE hg19")

## see table content
query("DESCRIBE snpArrayAffy5")

## get number of rows from table
print( query("select count(*) from snpArrayAffy6") )

## get number of rows from table
tempo6 = query("select * from snpArrayAffy6")


Friday, June 20, 2014

Inverse normalization function


my.invnorm = function(x)
{
 res = rank(x)
 res = qnorm(res/(length(res)+0.5))
 return(res)
}


Thursday, May 15, 2014

drop repeated vars keeping first row for given var



## function
## drop repeated vars but keeping first row for given var
droprep = function(df,repvar,sortvar)
{
    tab = table(df[,repvar])
    nametab = names(tab)
    uniquelist = nametab[tab==1]
    replist =  nametab[tab>1]
    ind = df[,repvar] %in% uniquelist
    res = df[ind,]
    tempo = df[!ind,]
    tempo = tempo[order(tempo[,sortvar]),]
    for(vv in replist)
    {
        rowa = tempo[tempo[,repvar]==vv,][1,]
        res = rbind(res,rowa)
    }
    return(res)
}

Monday, March 24, 2014

How to create MySQL database with Entrez Gene Database Description and Files


http://jura.wi.mit.edu/entrez_gene/

"Entrez Gene is NCBI's repository for gene-specific information. Access to this information either through the Entrez Gene website or by flat files via NCBI's ftp site can be time consuming and limiting in regards to the number of and what questions you can ask about the data. A better solution for intense data mining is to create a relational database. 
We offer our MySQL based database and data loading script as an easy-to-implement solution to this problem. While the ER diagram describes the database we created, we also offer the SQL syntax for both the tables and indexes. The data loading script, which is written in Perl, will automatically download Entrez Gene data files, parse the data and load it into the MySQL database."


Sunday, March 23, 2014

Thursday, March 6, 2014

How to start shiny application


Fire up R/RStudio, make sure you have the shiny package installed, and type

   library(shiny)
   runApp('~/vcs/rcg/haky')

where you replace '~/vcs/rcg/haky' with the path to the directory containing the ui.R, server.R and screen.tiff files, and the data subdirectory.  It should fire right up; you can then stop it by sending R an interrupt.


Monday, February 24, 2014

How to post R packages on cran


Here's the procedure for reference: upload the .tar.gz file, using ‘anonymous’ as log-in name and your e-mail address as password, to ftp://CRAN.R-project.org/incoming/ (note: use ‘ftp’ and not ‘sftp’ to connect to this server, and passive ‘ftp’ is more often successful) and send a message to CRAN@R-project.org about it (with your package name and version in the subject line of the form “CRAN submission package version”, and please do not submit a package by email). For a new submission, please note in the message that you have read and agreed to the CRAN policies.


Wednesday, February 19, 2014

How to access dbgap authorized files

As of 2/19/2014, I could log in directly through https://dbgap.ncbi.nlm.nih.gov/ using the Era Commons ID
Before I had to do the following steps
1. Log into Era Commons 
https://public.era.nih.gov/(you need an Era Commons ID)

2. Goto https://dbgap.ncbi.nlm.nih.gov/

3. Click log in

You should be in then.

Contributors

google