Tuesday, May 19, 2009

Implementing array in Stata

The simplest way in my opinion is to use


local `localname' : word `i' of `array'


Below is my example renaming a batch of variables from snp1or to snp74or with the corresponding SNP name.

local snpname rs10116277 rs1011970 rs10120688 rs1063192 rs10738604 rs10738607 rs10757260 rs10757261 rs10757278 rs10757282 rs10757283 rs10811650 rs10811658 rs10811659 rs10965187 rs10965197 rs10965215 rs10965232 rs10965235 rs10965243 rs12003027 rs13298881 rs1333034 rs1333040 rs1333050 rs1412829 rs1412831 rs1412832 rs1537370 rs1537375 rs1547705 rs16905597 rs16905599 rs1759417 rs17761319 rs17761446 rs2069421 rs2069422 rs2069423 rs2069425 rs2069426 rs2106119 rs2151280 rs2157719 rs2285329 rs2383207 rs2383208 rs2811708 rs2811709 rs2811712 rs2811715 rs2891169 rs3088440 rs3217973 rs3217976 rs3217980 rs3217981 rs3217982 rs3217983 rs3217985 rs3217986 rs3217987 rs3217988 rs3217989 rs3217992 rs3217993 rs3217994 rs3218018 rs3218020 rs3731213 rs3731217 rs3731225 rs3731238 rs3731239

local i 1
foreach var of varlist snp1or-snp74or {
local mysnp : word `i' of `snpname'
label var `var' `mysnp'
local i = `i'+1
}

Tuesday, April 07, 2009

Now and then

A young man unhappily single with good reason. For as long as he can remember, his romances travel the same track. First, the shock of love with its vertiginous rush and the sweet fire in his spine. Mad mutual devotion follows for weeks. Then the first alarming note: the trickle becomes a torrent and the torrent a cataract. He is lazy; he is thoughtless; his taste in restaurants is banal and his housekeeping habits a horror. When he can’t stand it any longer, he breaks off the relationship. Blessed silence and relief descend. As the weeks drag by into months, his newfound ease slides over into loneliness. The next woman he dates revels herself (after a brief time) to be the doppelgänger of his recently departed ex. Without a woman, his life is empty; with her, its misery. -- Gravity’s Incarnation in The General Theory of Love, p 117, 2000.

Friday, April 03, 2009

The easiest way to install ESS

If you know what "R" is, you probably are using EMACS and ESS plugin.
Installing EMACS is quite simple; however, ESS is a bit tricky to install. Anyway, after I read this post from the R-help mailing list, life is a lot easier. Thank you very much Schwartz.


That being said, it is easy enough to run ESS using the tarball, which is the current version as compared to the RPM. Un-tar it someplace and then add:

(load "PATH/TO/ess-5.3.11/lisp/ess-site")

in your ~/.emacs file so that it gets loaded. 'ess-site' actually
points to the lisp file 'ess-site.el' which will be in the 'lisp'
folder in the un-tarred file tree.

BTW, there is an ESS specific list:


and a newly formatted web site here with docs:


HTH,

Marc Schwartz

ํYou can get ESS tar ball from here http://ess.r-project.org/index.php?Section=download

Tuesday, March 31, 2009

Plotting matrix

# ----- Define a function for plotting a matrix ----- #
# source("http://www.phaget4.org/R/myImagePlot.R")
# Nice plot of data frame or matrix



myImagePlot <- function(x, ...){
min <- min(x)
max <- max(x)
yLabels <- rownames(x)
xLabels <- colnames(x)
title <-c()
# check for additional function arguments


if( length(list(...)) ){
Lst <- list(...)
if( !is.null(Lst$zlim) ){
min <- Lst$zlim[1]
max <- Lst$zlim[2]
}
if( !is.null(Lst$yLabels) ){
yLabels <- c(Lst$yLabels)


}
if( !is.null(Lst$xLabels) ){
xLabels <- c(Lst$xLabels)
}
if( !is.null(Lst$title) ){
title <- Lst$title
}
}
# check for null values
if( is.null(xLabels) ){


xLabels <- c(1:ncol(x))
}
if( is.null(yLabels) ){
yLabels <- c(1:nrow(x))
}

layout(matrix(data=c(1,2), nrow=1, ncol=2), widths=c(4,1), heights=c(1,1))

# Red and green range from 0 to 1 while Blue ranges from 1 to 0


ColorRamp <- rgb( seq(0,1,length=256), # Red
seq(0,1,length=256), # Green
seq(1,0,length=256)) # Blue
ColorLevels <- seq(min, max, length=length(ColorRamp))



# Reverse Y axis
reverse <- nrow(x) : 1
yLabels <- yLabels[reverse]
x <- x[reverse,]

# Data Map
par(mar = c(3,5,2.5,2))
image(1:length(xLabels), 1:length(yLabels), t(x), col=ColorRamp, xlab="",


ylab="", axes=FALSE, zlim=c(min,max))
if( !is.null(title) ){
title(main=title)
}
axis(BELOW<-1, at=1:length(xLabels), labels=xLabels, cex.axis=0.7)
axis(LEFT <-2, at=1:length(yLabels), labels=yLabels, las= HORIZONTAL<-1,


cex.axis=0.7)

# Color Scale
par(mar = c(3,2.5,2.5,2))
image(1, ColorLevels,
matrix(data=ColorLevels, ncol=length(ColorLevels),nrow=1),
col=ColorRamp,
xlab="",ylab="",


xaxt="n")

layout(1)
}
# ----- END plot function ----- #

Sunday, March 29, 2009

Friday, March 27, 2009

Group Folder

I found this description on Ubuntu forum http://ubuntuforums.org/showthread.php?t=576907
Re: Inheriting permissions

If you are sharing files with few people. You should create a group for that folder. http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/ Let's say the folder contains open office docs. Create a group called, /data1/washuDataReformatted and put all the users who need to write to that group. The users might be Jane, Bob, and John. Set folder to 770 on /data1 folder.

groupadd analysts
useradd -g analysts bhoom


If you already have stuff in that folder,

chmod -R 770 /data1


-R is recursive

After that set your setgid by typing

chmod g+s /data1

It will inherited the group permission now on.

Hope it works?!

Wednesday, March 18, 2009

At a glance : Mapping complex disease traits with global gene expression : Nature Reviews Genetics

At a glance : Mapping complex disease traits with global gene expression : Nature Reviews Genetics: "Nature Reviews Genetics 10, 184-194 (March 2009) | doi:10.1038/nrg2537

Mapping complex disease traits with global gene expression

William Cookson1, Liming Liang2, Gonçalo Abecasis2, Miriam Moffatt1 & Mark Lathrop3 About the authors"

Friday, March 06, 2009

NEJM -- Serotonin Rising -- The Bone, Brain, Bowel Connection

NEJM -- Serotonin Rising -- The Bone, Brain, Bowel Connection: "Most circulating serotonin arises from synthesis in the duodenum by specialized neuroendocrine enterochromaffin cells. The life cycle of serotonin begins with meal-induced mucosal stimulation of the gut,"

Umm... it is all connected. Eating, eating and eating...

Sunday, March 01, 2009

New Ph.D.s to Teach Harvard Undergrads -- Gaidos 323 (5915): 697 -- Science - Sent using Google Toolbar

"Saw this news on Science. This might be an interesting option for a preclinical department, or at least for my department, which always have a complain that we do not have enough staff to teach. We do not have enough time to do research either, as most of our research time is invaded by the time we have to spend teaching. One of my senior colleague said teaching should be our primary responsibility. Although I like teaching, I prefer research over teaching. In addition, we are supposed to do research as we should be one of the leading research university. Or else, I probably should look for jobs at other places that allow us to do both teaching and hand-on work. However, I guess that we do not have this option available yet in Thailand or at least at my work place. Hiring temporary teaching staff might help to solve the workload we have to teach medical students, and might allow more time to do research."

See the news below.

New Ph.D.s to Teach Harvard Undergrads -- Gaidos 323 (5915): 697 -- Science

HIGHER EDUCATION:
New Ph.D.s to Teach Harvard Undergrads


Susan Gaidos*

Harvard University plans to hire up to 20 recent Ph.D.s to teach undergraduate courses in a move that officials say will improve instruction and help students facing a tough job market.

The new College Fellows Program was announced last week in an e-mail to faculty and will go into effect this fall. Fellows will be paid $48,000 with full benefits to work in some 20 academic departments throughout the Faculty of Arts and Sciences. The program is open to all recent--since 2005--Ph.D. graduates. The awards are for 1 year, with a second year possible, and the money will come from the university's instructional budget.

"A large part of the goal was to support graduates and mentor excellent teaching among recent Ph.D.s, and [another] was to meet essential teaching needs in Harvard College," says Allan Brandt, dean of Harvard's Graduate School of Arts and Sciences. "We wanted to develop strong teaching for our Harvard College students and to make sure our teaching needs were met."

Each fellow will be assigned a faculty mentor, and teaching-focused seminars are planned. The program, Brandt says, "is designed for people who have a deep interest in university teaching." Fellows will be expected to carry 70% of the teaching load of a faculty member, leaving them some time to pursue their research. "At this career stage," says Brandt, "it's very important that they have some protected time to continue their research endeavors."

James Hanken, Alexander Agassiz professor of zoology, says the program offers new Ph.D. recipients "a sort of a temporary hold" in a tough job market. "If it's a teaching postdoc that doesn't consume all of your waking hours and leaves you time to do some research, I think it can be a good deal," he says.


Friday, February 20, 2009

Genetic Epidemiology Training Program

Just looked at the International Genetic Epidemiology Society (IGES) website on Graduate training program in genetic epidemiology.
http://www.geneticepi.org/educationwiki/tiki-index.php?page=Graduate+Training+Programs

It seems like most people do not recognize that we still have a graduate program in Genetic Epidemiology, or we just don't have a link where other people can look for. Google with "Genetic Epidemiology" and "graduate program" does not give a link for Hopkins on the top few page anymore (unlike 5 years ago, when I was looking for the program to apply for my PhD). Are others program getting bigger? Or we have just hit a growth stunt? Where are we going 10 years from now? Good question!? I have NO answer, though.
Powered By Blogger