Thursday, December 9, 2010

Google code university::구글에서 제공하는 프로그래밍 교육 자료


기말 시험을 앞두고, 평소에 들어가보지도 않던 웹들을 이곳 저곳 들어가보다가 Google Code University 라 명명한 곳에서, 프로그래머들을 위한 교육 자료를 제공하고 있는걸 발견했다.

교육 카테고리는 크게
  • 프로그래밍 언어
  • 웹 프로그래밍
  • 웹 보안
  • 알고리즘
  • 안드로이드
  • 분산 시스템
  • 구글 API 및 툴
  • Tool 101 ( 리눅스, MySQL, Software configuration )
로 나뉘에져 있고 그 밑으로 하위 주제들에 대한 페이지들이 죽 연결되어 있는 구조다.

프로그래밍 언어에는 C++, Java, Python, Go 네 가지에 대해서만 자료가 제공된다. Perl 이 빠져 있어서 살짝 아쉽 ,,

각 세부 항목들에서 제공하는 교육 자료를 살펴보면, 대게 미국의 대학들에서 제공하는 교육자료들이 링크 되어 있는데, 밑에 Submit a course 라는 메뉴를 누르고 들어가보면, 사용자들이 직접 자료를 제공하여 만들어지는 페이지 라는 걸 확인할 수 있다.

구글 자체에서 심혈을 기울여 만들어진 페이지가 아니라, 당연히 전체적으로 자료들 간 연결성이나 통일성이 떨어지는건 어쩔 수 없지만, 자료들이 점점 업데이트 되면 꾀나 쓸만한 reference 페이지로 사용할 만 한 것 같다.




Monday, December 6, 2010

23andMe 서비스 신청



Thanks giving 맞이 대 바겐세일에 나선 23andMe 서비스를 단돈 $99 에 신청했다.
실제로는 Kit 배송료 약 $14, 그리고 세일기간엔 의무적으로 분석 maintainance 서비스를 12개월간 가입해야 해서 이 비용 ( $5 X 12 ) 해서 총 $174 가 드는 셈인데, 그렇게 해도 원래 서비스 비용 $400 에 비하면 여전히 50% 이상 싼 가격이다.

신청 후 kit 은 3일 만에 배달되었고, 거품이 엄청 일어난 침을 겨우겨우 요구 용량까지 채우고, 동봉된 반송 봉투에 Kit 을 담아 우체통에 넣어 보냈다. 이제 2-4주 정도 지나면 분석 결과를 확인할 수 있다.

Wednesday, June 16, 2010

[R::manual] 무규칙 데이터 읽기

R은 항상 format 된 table 데이터를 읽어 graphing 하는데만 사용해왔는데,
이번에 특정 format이 존재하지 않는 데이터를 처음으로 처리해봤다.
이 과정을 정리해 본다.

DATA format

1 2 3 4 5
1 2 3
1 2 3 4 5 6 7 8 9 10

과 같이 각 row의 column 개수가 일정하지 않는 input data

1. Reading file

먼저 readLines 함수를 사용해 파일을 읽는다.


>raw_data=readLines('file')


이렇게 읽은 결과는

[1] "1 2 3 4 5"
[2] "1 2 3"
[3] "1 2 3 . . . 10"

과 같이 각 row가 list에 string 으로 저장된다.

2. String split

각 row의 string을 각각의 numeric value 로 구분한다.


> data=strsplit(da,' ')


결과는
"1 2 3 4 5" 가
"1", "2", "3","4","5" 으로 각 numeric value별로 떨어져 저장

3. Converting character to numeric value

"1","2" 와 같이 각 numeric value 가 떨어진 것 처럼 보이나,
이들은 numeric variable이 아니라, 아직까지 character variable 이다.

실제 이 숫자들을 가지고, plotting, statistic test를 수행하기 위해서는
이들을 numeric variable로 인식되도록 해야 한다.

이때, as.numeric 함수를 쓸 수 있는데, 문제는 이 함수의 입력값이
독립 variable이어야 한다는 것이다. 즉, list 형태의 데이터는 독립
variable로 변환해야 이 함수를 사용할 수 있다.
이를 위해 unlist 함수를 사용한다.

이들 함수를 한번에 쓰면,


> final=as.numeric( unlist( da ) )


이 때, da 가 multi level list 인 경우( list 여러개로 이뤄진 경우 )
위의 방법을 쓰면 서로 다른 level의 list를 구분없이 하나의 list로
합쳐 final로 합쳐 진다.

예를 들면,

[[1]]
[1] 1 2 3 4 5
[[2]]
[2] 6 7 8 9

로 구성된 da 라면, unlist(da) 의 결과는

[1] 1 2 3 4 5 6 7 8 9

가 된다. 원하는 결과는 원 list format 를 유지하는 경우가 대부분 일 것이다.
이런 경우에는 각 list level에 대해 각각 위 명령을 수행하여야 하는데,
일일이


a=as.numeric(unlist(da[1]))
b=as.numeric(unlist(da[2]))


와 같이 각각의 list 를 처리해 줄 순 없는 일이다.
이를 한번에 처리 한다면 아래와 같이 정리할 수 있다.


for(i in 1:length(da) ) {
da[[i]]=as.numeric( unlist(da[[i]] ) )

}

Sunday, April 25, 2010

University ranking on Bioinformatics [ 생명정보학 대학 랭킹 ]


I ranked universities according to the number of publications in journals on bioinformatics. The journals concerned for this task are Bioinformatics, BMC Bioinformatics and Plos computational biology. The journal selection criteria might be controversial since articles on bioinformatics have been published nearly all journals on 'biology', including top science journal Nature or Science. However, I selected the three journals for further analysis since it requires additional mandatory validation for articles published in the other journals to identify whether a given article is on bioinformatics or not( I used automatic selection and counting approach for this task). Moreover, the selected three journals are top ranked journals in the field of bioinformatics ( according to ISI impact factor ) so that ranking according to the publication numbers in these journals is not depend only on number of publications but the number of 'high' quality publications.

METHOD

  • Search journal : I used CPAN perl module 'WWW::Search::PubMed' to retrieve information of papers published in three journals. To retieve Affiliation information, I added lines of codes.
  • Control variation of university name : Majority of papers used standard official name to specify each university. Howevr, some of papers used university name which is subtly different from the standard one. Since it requires mandatory validation, I didn't consider these variations. I only consider universities are the same if they used exactly the same name. However, I controled terms for 'University of California' . There are branches of universities for 'University of California', such as UC san diego, UC los angeles , UC berkely, etc. And generally, the university name is divided by comma (, ) which is a seperator in affiliation line into two parts, 'University of California' and city name such as 'Los Angeles', 'San diego' , etc. So I combined university name and the city name if 'University of California' is stated alone followed by comma without city name.

Overall ranking
( Top 50 )

#colum 1: Ranking
#colum 2: Number of publications
#colum 3: University name
( Non US universities are orange colored )

1 108 UNIVERSITY OF CALIFORNIA SAN DIEGO
2 88 STANFORD UNIVERSITY
3 72 COLUMBIA UNIVERSITY
3 72 UNIVERSITY OF WASHINGTON
3 72 UNIVERSITY OF MANCHESTER
6 71 UNIVERSITY OF MICHIGAN
7 69 YALE UNIVERSITY
8 63 UNIVERSITY OF CALIFORNIA BERKELEY
8 63 UNIVERSITY OF CAMBRIDGE
10 60 WASHINGTON UNIVERSITY
11 59 UNIVERSITY OF OXFORD
12 58 TEL AVIV UNIVERSITY
12 58 UNIVERSITY OF TOKYO
14 56 NATIONAL UNIVERSITY OF SINGAPORE
15 53 PRINCETON UNIVERSITY
16 52 UNIVERSITY COLLEGE LONDON
17 48 UNIVERSITY OF MINNESOTA
17 48 UNIVERSITY OF QUEENSLAND
19 47 IOWA STATE UNIVERSITY
20 45 BOSTON UNIVERSITY
21 44 UNIVERSITY OF TORONTO
22 42 UNIVERSITY OF CALIFORNIA IRVINE
22 42 UNIVERSITY OF PITTSBURGH
24 41 CORNELL UNIVERSITY
24 41 KYOTO UNIVERSITY
24 41 UNIVERSITY OF SOUTHERN CALIFORNIA
27 40 UNIVERSITY OF CALIFORNIA SAN FRANCISCO
28 39 KAIST ( Korea Advanced Institute of Science & Technology )
28 39 TEXAS A&M UNIVERSITY
28 39 UNIVERSITY OF BRITISH COLUMBIA
31 38 JOHNS HOPKINS UNIVERSITY
32 37 HARVARD UNIVERSITY
32 37 UNIVERSITY OF CALIFORNIA DAVIS
34 36 UNIVERSITY OF PENNSYLVANIA
35 35 CARNEGIE MELLON UNIVERSITY
35 35 UPPSALA UNIVERSITY
35 35 UNIVERSITY OF MARYLAND
38 33 BIELEFELD UNIVERSITY
39 31 UNIVERSITY OF CALIFORNIA SANTA CRUZ
40 30 PEKING UNIVERSITY
40 30 UNIVERSITY OF TEXAS SOUTHWESTERN MEDICAL CENTER
40 30 UNIVERSITY OF GEORGIA
43 29 INDIANA UNIVERSITY
43 29 UNIVERSITY OF GLASGOW
43 29 UNIVERSITY OF CALIFORNIA LOS ANGELES
43 29 TSINGHUA UNIVERSITY
47 28 OHIO STATE UNIVERSITY
48 27 Seoul National University
49 26 TECHNICAL UNIVERSITY OF DENMARK
49 26 PENNSYLVANIA STATE UNIVERSITY



Rising universities

After HGP, bioinformatics recogenized as one of the most important field of genome revolution. Universities that did not specially drive their effort on bioinformatics before the time had started bioinformatics research with large investment. Therfore, the overall ranking might have undergone lots of changes.

To find these variation, I ranked again according to relative rank increase( rank_after_2001 - rank_before_2005 / rank_before_2001).
Range of publication time is divided into two duration, before 2001 and after 2005.
Universities without any publication before 2001 were not considered for this analysis.


[ Top 10 raising university]

#colum 1: Ranking
#colum 2: University name
#colum 3: relative rank difference
#colum 4: ranking for 1998-2000
#colum 5: ranking for 2006-2010

1.UNIVERSITY OF CALIFORNIA SAN DIEGO 0.93 15 1
2.UNIVERSITY OF WASHINGTON 0.92 39 3
3.STANFORD UNIVERSITY 0.66 6 2
4.TEL AVIV UNIVERSITY 0.56 39 17
4.UNIVERSITY OF QUEENSLAND 0.56 39 17
6.YALE UNIVERSITY 0.5 6 3
7.IOWA STATE UNIVERSITY 0.41025641025641 39 23
8.UNIVERSITY OF SOUTHERN CALIFORNIA 0.35 39 25
8.UNIVERSITY OF TORONTO 0.35 39 25
8.KYOTO UNIVERSITY 0.35 39 25


Thoughts on the ranking


1. Can I say that high ranked universities are better than universities in low ranked?
  • University is different from research institution. I think university ranking should consider not only research performance, but also how successfully they educate student. This ranking is based only on number of publications so that it only consider research performance. Therefore, this ranking should not be considered to reveal overall value of universities.

2. How does UCSD excel the other top schools?
  • UCSD is ranked around 7-10 when the ranking is based only on 'Bioinformatics' or 'BMC bioinformatics'. However, UCSD is top ranked with overwelming number of publications when it comes to 'Plos computational biology' journal. Since Plos family journals were initiated with tight relationship with faculty members at UCSD, they have willingness to publish papers in Plos journal. Moreover, Philip Bourne, a professor at UCSD in the field of bioinformatics, has been contributed a series of editorials, ' Ten simple rule ' advise series, in Plos Computational biology, which are not research papers, but counted as equally as research papers to be considered for ranking.
3. Some most prominent universities such as Harvard ranked lower compared to others, are they really bad on Bioinformatics or computational biology?
  • As I described in the beginning, this ranking is only based on top three journals in the field of bioinformatics or computatinoal biology. If the other journals were considered, the ranking would be changed a lot.
4. USA vs. the other countries
  • In the top 10 list, only Cambridge and Manchester are universities out of USA. In top 20, there are 8 and 12 in top 30. Regardless of drawbacks of ranking criteria, it's ture that USA is a leading country in this field.
  • List of countries other than USA in top 30 ranking are Japan, Canada, Israel, Korea, Singapore and Austrailia. 3 Aisan countries have 4 universities ranked within top 30.

Tuesday, March 30, 2010

시퀀스에서 Di-nucleotide frequency 계산 문제.

지난해 pung96님의 블로그에 올라왔던 Di-nucleotide composition frequency 세기 문제( http://perlog.pung96.net/20 ) 를 다시 한번 언급해 본다.

문제를 다시 정리해 보면,

AGATAGCGATAGCG
AGATGACGATAGAG
...

위 처럼 DNA 서열이 담긴 input 파일이 있을 때, DNA base 두개씩을 끊은 dinucleotide ( e.g., AG, CT ) 와 같은 16개 조합( DNA base가 4개 이므로 2개의 조합 가지 수는 16개 )의 빈도를 계산하는 것이 원글의 문제다. 이때, 앞에서 순서대로 2개씩 읽되, window size는 1로 하여 1칸씩 옮겨가며 2개씩 읽어 조합을 계산해야 한다.

구체적으로 AGAA 네개 DNA 서열인 경우, AG, GA ,AA 세개의 dinucleotide 조합으로 계산해야 한다는 것이다.

TIMTOWTDI, perl의 특성답게 이를 해결하는 방법은 상당히 다양한데, pung96님의 글에 언급되지 않은 내용을 추가로 정리해 보고자 한다.

substr을 이용하는 경우 ( DNA 서열은 $seq에 저장되어 있는 경우 )

for( my $i=0; $i< length( $seq ) - 1 ;$i++ ){
$count{ substr($seq,$i,2) }++;
}


정규식의 lookahead 이용하는 경우,

my @di=$seq=~/(?=(\w{2}))/g;
$count{$_}++ for @di;


이걸 한줄로 줄이면,

$count{$_}++ for $seq=~/(?=(\w{2}))/g;


반복을 while로 돌리면,

$count{$1}++ while $seq=~/(?=(\w{2}))/g;


map 에 넣으면,

map{ $count{$_}++ } $seq=~/(?=(\w{2}))/g;

와 같은 방식으로도 문제를 해결할 수 있다. 포스팅의 요지는 lookahead 를 이용한 정규식 사용!!

사족을 좀 덧붙여 보면, 이 문제는 연세대 생명공학과 대학원 이인석 교수의 bioinformatics 수업 과제 문제다. 지난해와 올해 연구소에 연대 대학원 학생분들이 있어, 내게 이 문제에 대한 조언을 구해와 본의 아니게 2년 연속으로 이 문제에 대해 생각해볼 기회가 생겨, 포스팅해 본다.

Tuesday, March 2, 2010

HelloGene :: 한국 최초 개인유전체 정보 분석 서비스

KOBIC 센터장이었던 박종화 박사가 합류하면서 이목을 끌었던 테라젠(Theragen)에서 드디어 한국에선 최초로 개인유전체 분석 서비스를 출시하였다. 서비스 이름은 HelloGene 이며, 웹사이트 ( htttp://hellogene.co.kr/pgp/ )를 통해 서비스 신청을 할 수 있다.


서비스 내용을 살펴보면, 23andME에서 최초로 서비스 했던 SNP 칩 분석을 통한 개인유전체 분석 서비스와 Knome, DecodeME 등의 회사가 제공하고 있는 Whole genome sequencing 분석 서비스 두가지 모두를 서비스 상품으로 내놓고 있다.

가격은 SNP칩 분석 서비스의 경우 1,100,000( 백십만원, 일반형 ), Whole genome sequencing의 경우 150,000,000 (1억 5천만원, 일반형) 으로 23andME의 SNP칩이 $390, Knome의 whole genome sequencing이 $68,500 임을 감안하면 HelloGene의 서비스 가격이 2배 이상으로 비싼 편이다.

그러나 기존의 미국계 개인유전체 회사들의 분석 내용이 서구인에 대한 연구 결과를 바탕으로 한 것으로, 한국인의 유전체 분석에 오류가 상당하다는 단점이 있었기 때문에, HelloGene 서비스의 분석에서 이런 부분을 보완한다면 상대적으로 높은 가격에 의의를 부여할 수 있을 것 같다.

지난 겨울 직접 테라젠(Theragen, Teragen이 아님)에 방문했을 때만 해도 아직 연구소 셋팅이 제대로 되지 않은 상태여서, 서비스는 고사하고 정상적으로 연구 기반을 잡는데만 상당한 시간이 걸릴 것으로 생각했었는데, 벌써 이런 상용 서비스를 개시하다니 상당히 놀랍다.

테라젠의 HelloGene 서비스를 위시하여 한국에도 개인유전체 관련 산업이 시작되었다. 테라젠이 가천의대와 밀접한 연관을 가지고 연구를 하고 있어, 병원의 환자 의료 정보 시스템과의 연계 등에 비전을 가지고 연구를 진행한다면, 세계적으로도 유례없는 개인유전체 기반 의료 서비스를 선보일 수도 있을거라 생각한다. ( 병원의 환자 의료 정보에 대한 접근은 개인 정보 접근 등에 제한이 많은 외국보다 한국이 훨 수월하다고 생각한다.)

아뭏든, 최초의 한국형 개인유전체 분석 서비스인 HelloGene의 선전을 기원한다!!

Monday, March 1, 2010

Jquery이용한 dynamic 페이지 스타일

Javascript 라이브러리인 Jquery를 이용하면, 간단하게 복잡한 Javascript 기능을 구현할 수 있다.
최근에 간단한 웹DB를 만들면서 로딩된 page에 CSS 스타일을 적용하는 기능을 구현하였는데, Jquery( 및 Javascript) 를 이용할 때, 주의해야할 사안에 실수를 저지르는 바람에 한참 삽질을 했는데, 이를 정리해 본다.

먼저 아무런 내용이 없는 html 구조를 아래와 같이 설정하자.
(이 페이지의 html코드에서 html tage (<, >) 가 허용이 안되어, tag 괄호를 <> 대신 () 를 사용하였다. )

(html)
(div id="main")

(/div)
(html)


그다음 Jquery를 이용해서, id=main 부분에 외부 html 파일을 읽어 뿌려주는 부분을 html head부분에 script로 추가한다.

(script)
$(document).ready(function(){
$(#main).load('content.html');
});
(/script)



* 여기서 첫번째 문제, load된 html 내용에 원 html 파일에 적용된 CSS 가 적용될까?
적용된다. 페이지에 설정된 CSS 이기 때문에 load되어 원 페이지의 CSS 규칙 적용을 받는 내용에도 CSS 규칙이 적용된다.

다시 page로 돌아가서, 이번에는 load된 html의 특정 div id 를 가진 부분에 대해 CSS 규칙을 추가한다.

(script)
$(document).ready(function(){
$(#main).load('content.html');
$('#top').addClass('css_top'); //id=top에 CSS 규칙 css_top을 적용한다.
(/script)



* 여기서 두번째 문제, load된 html의 특정 부분에 CSS 규칙이 적용될까?
정답은 조건적으로 그렇다 이다. 문제는 네트워크 지연에 있다. AJAX방식의 모든 구현에서 발생하는 문제로, script에서는 load 이후, css가 추가되는 것 처럼 보이지만, 실제 html이 load되는 시점은 html을 읽어오는 동안의 '지연' 이 발생하므로 css 추가 부분이 적용된 이후가 될 수 있다. 이런 경우엔 css 규칙 적용 부분이 먼저 실행되고 html이 로딩이 되었기 때문에, css 규칙 추가가 이루어 지지 않는다.

실제로는 plain html 파일인 경우, 지연효과가 미미하여, 이 문제가 발생하지 않을 수 있는데, 내가 작업하는 상황에서는 읽어오는 파일이 그 자체로 Mysql 을 긁고 processing 을 하여 조금 시간이 걸리는 php 파일이었기 때문에, 이 문제가 발생하였다.

이런 상황에서 문제없이 순서대로 원하는 기능을 구현하기 위해서는 '콜백' 기능을 이용해야 한다. 즉 각 jquery 라인을 순서대로 실행하도록 조건을 걸어두는 것이다.

콜백 기능 구현은 간단한데, 위의 상황에서 html 파일을 load하고 난 이후, css 규칙을 추가하는 콜백 함수를 구현하면, 원하던 기능을 문제없이 수행할 수 있다.


(script)
$(document).ready(function(){
$(#main).load('content.html', function(){
$('#top').addClass('css_top');
});
});
(/script)