생물정보학 끄적끄적

[Linux] 데이터 분석 - 완전 기초

Hazel Y. 2023. 12. 19. 12:19

지난 주 유전학까지 수료한 나에게 한 달 남짓의 방학 비슷한 기간이 생겼다.

 

제일 빠른 분자 생물학 수업이 내년 1월 중순에야 개강하기 때문이다.

 

그 동안 뭘 할까 생각을 해 보았다.

 

아무것도 안 하고 쉬면서 시간을 보내기에는 그저 흘려 보내게 될 시간이 너무 아까웠다.

 

그래서 이것저것 자료를 구글링해 본 결과, The Biostar Handbook이라는 꽤 좋아 보이는 Bioinformatics 자습서를 발견했고, 그 책으로 한 달 동안 공부해 보기로 결정했다.

(그래서 한 달 동안의 Bioinformatics 공부 기록은 해당 책의 내용이 다수 포함되어 있을 예정이다.)

 

그리고 요즘 블로그를 정말 너무 방치만 해 두고 있는 것 같아서 아무리 공부할 게 많아서 바쁘더라도 공부 기록이라도 대충 해 놓으려 한다.

 

그럼 혼자 공부하는 이 한 달이 더 의미 있어질 듯하기 때문이다.

 

(참고로 해당 책의 모든 유전체 데이터 분석 예제들은 Linux command 창에서 이루어진다. 그리고 나는 그러한 방식으로 데이터 분석을 하는 것은 아예 처음이다. 그래서 완전 기초적인 내용이 다뤄질 예정이다.)


 

일단 첫 예제에 사용되는 데이터셋은 S.cerevisiae 의 chromosomal features, coordinates, and gene descriptions 데이터가 포함된 SGD_features.tab 이라는 데이터셋이다.

(Bioinformatics 분야에서는 tab-delimited 텍스트 파일이 많이 쓰인다고 한다.)

 

해당 데이터셋은 https://www.yeastgenome.org/ 에서 찾을 수 있다.

 

Saccharomyces Genome Database | SGD

TAGC2024 The Allied Genetics Conference March 05 to March 10, 2024 - National Harbor | Washington DC Metro Area 32nd Fungal Genetics Conference March 12 to March 17, 2024 - Asilomar Conference Grounds, Pacific Grove, CA 16th Yeast Lipid Conference May 29 t

www.yeastgenome.org

 

 

1. 파일 내용 보기

$ cat SGD_features.tab

 

 

2. 파일 내 행수, 단어 수, 글자 수 추출

$ cat SGD_features.tab | wc
  16454  425719 3264490

 

→ 16454 lines, 425719 words, 3264490 characters

 

 

3. 행수 추출

$ cat SGD_features.tab | wc -l
16454

 

 

4. 첫 10개 행 추출

$ cat SGD_features.tab | head
S000002143      ORF     Dubious YAL069W                 chromosome 1            1       335     649     W               1996-07-31      1996-07-31      Dubious open reading frame; unlikely to encode a functional protein, based on available experimental and comparative sequence data
S000031098      CDS                                     YAL069W         1       335     649     W               1996-07-31      1996-07-31
S000028594      ORF     Dubious YAL068W-A                       chromosome 1            1       538     792     W               2003-07-29      2003-07-29 Dubious open reading frame; unlikely to encode a functional protein, based on available experimental and comparative sequence data; identified by gene-trapping, microarray-based expression analysis, and genome-wide homology searching
S000031372      CDS                                     YAL068W-A               1       538     792     W               2003-07-29      2003-07-29
S000121252      ARS             ARS102          ARSI-1  chromosome 1            1       707     776                     2014-11-18      2014-11-18|2007-03-07       Autonomously Replicating Sequence
S000028862      telomere                TEL01L                  chromosome 1            1       801     1       C       -64     2003-09-09      2003-09-09 Telomeric region on the left arm of Chromosome I; composed of an X element core sequence, X element combinatorial repeats, and a short terminal stretch of telomeric repeats
S000028864      telomeric_repeat                                        TEL01L          1       62      1       C               2003-09-09      2003-09-09 Terminal telomeric repeats on the left arm of Chromosome I
S000028865      X_element                                       TEL01L          1       801     337     C               2003-09-09      2003-09-09      Telomeric X element Core sequence on the left arm of Chromosome I; contains an ARS consensus sequence, an Abf1p binding site consensus sequence and two small overlapping ORFs (YAL068W-A and YAL069W)
S000028866      X_element_combinatorial_repeat                                  TEL01L          1       336     63      C               2003-09-09      2003-09-09  Telomeric X element combinatorial repeat on the left arm of Chr I; contains repeats of the D, C, B and A types, as well as Tbf1p binding sites; formerly called SubTelomeric Repeats
S000002142      ORF     Verified        YAL068C PAU8    seripauperin PAU8       chromosome 1            1       2169    1807    C               1996-07-31 1996-07-31       Protein of unknown function; member of the seripauperin multigene family encoded mainly in subtelomeric regions

 

 

5-1. 특정 단어/패턴이 존재하는 행 추출

$ cat SGD_features.tab | grep YAL069W --color=always | head
S000002143      ORF     Dubious YAL069W                 chromosome 1            1       335     649     W               1996-07-31      1996-07-31      Dubious open reading frame; unlikely to encode a functional protein, based on available experimental and comparative sequence data
S000031098      CDS                                     YAL069W         1       335     649     W               1996-07-31      1996-07-31
S000028865      X_element                                       TEL01L          1       801     337     C               2003-09-09      2003-09-09      Telomeric X element Core sequence on the left arm of Chromosome I; contains an ARS consensus sequence, an Abf1p binding site consensus sequence and two small overlapping ORFs (YAL068W-A and YAL069W)

 

* command 창에는 YAL069W 이 붉은색으로 나타난다.

 

 

5-2. 특정 단어/패턴이 존재하지 않는 행의 수 추출

$ cat SGD_features.tab | grep -v Dubious | wc -l
15737

 

 

6. 추출 결과 새 파일에 저장

$ cat SGD_features.tab | grep YAL069W > match.tab

 

* 새 파일명: match.tab

 

 

7-1. protein-coding gene (ORF) 개수 (열 추출)

$ cat SGD_features.tab | cut -f 2 | grep ORF | wc -l
6604

 

 

7-2. 여러 열 추출

$ cat SGD_features.tab | cut -f 2,3,4 | grep ORF | wc -l
6604

 

 

8. 각 feature type별 행수 추출

$ cat SGD_features.tab | cut -f 2 > types.txt

$ cat types.txt | sort | uniq -c | head
    352 ARS
    196 ARS_consensus_sequence
   7074 CDS
     50 LTR_retrotransposon
   6604 ORF
      2 W_region
     32 X_element
     28 X_element_combinatorial_repeat
      3 X_region
     19 Y_prime_element

$ cat types.txt | sort | uniq -c | sort -rn | head
   7074 CDS
   6604 ORF
    484 noncoding_exon
    383 long_terminal_repeat
    377 intron
    352 ARS
    299 tRNA_gene
    196 ARS_consensus_sequence
     91 transposable_element_gene
     77 snoRNA_gene

$ cat types.txt | sort-uniq-count-rank | head
7074    CDS
6604    ORF
484     noncoding_exon
383     long_terminal_repeat
377     intron
352     ARS
299     tRNA_gene
196     ARS_consensus_sequence
91      transposable_element_gene
77      snoRNA_gene
# tab-delimited output

Reference

The Biostar Handbook: 2nd Edition - István Albert