Saturday, June 2, 2012

if

If
by Rudyard Kipling

If you can keep your head when all about you
Are losing theirs and blaming it on you;
If you can trust yourself when all men doubt you,
But make allowance for their doubting too;
If you can wait and not be tired by waiting,
Or, being lied about, don't deal in lies,
Or, being hated, don't give way to hating,
And yet don't look too good, nor talk too wise;

如果周围的人毫无理性地向你发难,你仍能镇定自若保持冷静
如果众人对你心存猜忌,你仍能自信如常并认为他们的猜忌情有可原;
如果你肯耐心等待不急不躁,
或遭人诽谤却不以牙还牙,
或遭人憎恨却不以恶报恶;
既不装腔作势,亦不气盛趾高;

If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
If you can meet with triumph and disaster
And treat those two imposters just the same;
If you can bear to hear the truth you've spoken
Twisted by knaves to make a trap for fools,
Or watch the things you gave your life to broken,
And stoop and build 'em up with wornout tools;

如果你有梦想,而又不为梦主宰;
如果你有神思,而又不走火入魔;
如果你坦然面对胜利和灾难,对虚渺的胜负荣辱胸怀旷荡;
如果你能忍受有这样的无赖,歪曲你的口吐真言蒙骗笨汉,
或看着心血铸就的事业崩溃,仍能忍辱负重脚踏实地重新攀登;

If you can make one heap of all your winnings
And risk it on one turn of pitch-and-toss,
And lose, and start again at your beginnings
And never breath a word about your loss;
If you can force your heart and nerve and sinew
To serve your turn long after they are gone,
And so hold on when there is nothing in you
Except the Will which says to them: "Hold on";

如果你敢把取得的一切胜利,为了更崇高的目标孤注一掷,
面临失去,决心从头再来而绝口不提自己的损失;
如果人们早已离你而去,你仍能坚守阵地奋力前驱,
身上已一无所有,唯存意志在高喊“顶住”;

If you can talk with crowds and keep your virtue,
Or walk with kings - nor lose the common touch;
If neither foes nor loving friends can hurt you;
If all men count with you, but none too much;
If you can fill the unforgiving minute
With sixty seconds' worth of distance run -
Yours is the Earth and everything that's in it,
And - which is more - you'll be a Man my son!

如果你跟村夫交谈而不变谦虚之态,
亦或与王侯散步而不露谄媚之颜;
如果敌友都无法对你造成伤害;
如果众人对你信赖有加却不过分依赖;
如果你能惜时如金利用每一分钟不可追回的光阴;
那么,你的修为就会如天地般博大,并拥有了属于自己的世界,
更重要的是:我的儿子,你成为了一名真正的男子汉!

Monday, May 14, 2012

R

1. Ubuntu
sudo apt-get install r-base r-base-html r-doc-html

2. getting help on a function
help(mean)
?mean
example(mean)

3. getting and setting the working directory
 getwd()
 setwd()

4. Accessing the functions in a package
library(packageName)

5. Accessing built-in datasets
data(dsname, package="pkname")

6.installing packages from CRAN
install.packages("packagename")

7. running a script
source("myScript.R")

8. Running a batch script
R CMD BATCH scriptfile outputfile

--slave, inhibiting echo of the input

Rscript myScript.R arg1 arg2 arg3

9. loading packages
require(tseries)

10. redirecting output to a file
cat("The answer is", answer, "\n", file="filename")

cat(data,file="filename", append=TRUE)

sink("filename") # begin writing output to file

....

sink() # resume writing output to console

11. reading fixed-width records
read.fwf("filename", widths=c(w1,w2,...wn))

12. reading tabular data files (white space)
read.table("filename")

13. reading from csv files
read.csv("filename")

14. writing to csv files
write.csv(x,"filename", row.names=FALSE)

15. Selecting data frame columns by name
dfrm[["name"]]
dfrm$name

16. selecting rows and columns
select columns
subset(dfrm, select=colname)
subset(dfrm, select=c(colname1, colname2, ... colnamen))

select rows
subset(dfrm, subset=(colname > 0))
subset(dfrm, select=c(predictor, response),subset=(response > 0))

17. removing NAs from a data frame
clean <- na.omit(dfrm)

18. excluding columns by name
subset(dfrm, select=-badboy) # all columns except badboy

19. merge data frames by common column
m <- merge(df1, df2, by="name")

20. accessing data frame contents more easily
attach(dataframe)

21. converting one atomic value to another
as.character(x)
as.complex(x)
as.numeric(x)
as.double(x)
as.integer(x)
as.logical(x)

22.




Wednesday, March 7, 2012

openssh server on ubuntu

sudo apt-get install openssh-server

ssh-server 配置文件位于:
/etc/ssh/sshd_config
在这里可以定义ssh的服务端口,默认为22,为了更安全,建议更改,然后重启ssh服务
sudo /etc/init.d/ssh restart

Sunday, March 4, 2012

wii刻盘

1.建议使用酒精 1.9.5 以上版本来刻盘..
第一: 下载网上的游戏一般都为 ISO
第二: 先打开酒精..用其虚拟光驱把 ISO 读出并加载..
第三: 使用酒精制作其虚拟光驱的 ISO ->生产 WiiGame.mdf 和 WiiGam.mds (镜像制作向导)
第四: 使用酒精选择烧录 WiiGame.mdf 和 WiiGam.mds.. (镜像烧录向导)
第五: 放入刻录盘 DVD+-R..烧录方式: DVD-DAO (反正是默认) / 4X~6X 速度刻录!
2。GCM格式的镜像用ImgBurn烧录 4x

Friday, February 17, 2012

Affymetrix 6.0 call genotype without .ARR file

Affymetrix Genotyping Console export plink file

My colleague just got the genotyping data typed by Affymetrix 6.0 chips. Delivered to him in CEL files. After QC and genotype call, he want to analyze the data using the popular software Plink.

There was an option in Affymetrix Genotyping Console (AGC) as Exporting to Plink Format, however it requires ARR file which specify the sample attribution, ARR file was produced by Affymetrix GeneGchip Command Console (AGCC) and the process to make it was not that straight forward.

And here is an easy way to use the Affy 6.0 genotyping data in Plink without the ARR file.
Since Plink support transposed PED (tped) format as input, which is almost identical to the exported genotyping format by AGC. You just need to simply modify the file a little bit to fit the requirement. An example of the exported genotyping data file is as below:

#GenomeWideSNP_6.na30.annot.db
#%genome-version-ucsc=hg18
#%genome-version-ncbi=36.1
Probe Set ID sample1 sample2
SNP_A-2131660 CC CC
SNP_A-2131666 CC CT

To make the tped file, the annotation lines need to be skip (lines begin by #)
and the chromosome number/morgan position/physical position should be added in to the beginning of each SNP typing line.all these infomation will be easily get in the annotation file of affymetrix 6.0.

Tfam file which contain individual and family info should be made afterword.
when these two files are ready, it is simply to use the plink to convert it into bed format as

plink --tped tpedfile --tfam famfile --recode --make-bed --out newbedfile name
Update: Forgot to mention that the genotype data in tped data should be like "C C" rather "CC"
there should be a tab between otherwise you will get error message.
 
source "http://geneticsnote.blogspot.com/2010/09/gwas-data-export-to-plink.html"

Monday, January 9, 2012