Creative Commons License
This blog by Tommy Tang is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

My github papge

Saturday, December 7, 2013

GEOquery to access GEO datasets

I was reading a paper Dual functions of Tet1 in transcriptional regulation in mouse embryonic stem cells , and wanted to re-analyze the microarray data.
In the paper, Hao wu et.al. knocked down Tet1, a protein can convert 5-methylcytosine to 5-hydroxymethlycytosine, and looked at gene expression change in mouse ES cells.

It was my first time to look at mouse microarray data set, but I was aware of that GEOquery, a bioconductor package, can do the job very easily. I will lay down the R code first.


some output from the code:

> show(pData(phenoData(gse[[1]]))[,c(1,6,8)])
                                              title type                   source_name_ch1
GSM659775                          Control KD, rep1  RNA         control KD mouse ES cells
GSM659776                          Control KD, rep2  RNA         control KD mouse ES cells
GSM659777                          Control KD, rep3  RNA         control KD mouse ES cells
GSM659778                          Control KD, rep4  RNA         control KD mouse ES cells
GSM659779                             Tet1 KD, rep1  RNA            Tet1 KD mouse ES cells
GSM659780                             Tet1 KD, rep2  RNA            Tet1 KD mouse ES cells
GSM659781                             Tet1 KD, rep3  RNA            Tet1 KD mouse ES cells
GSM659782                             Tet1 KD, rep4  RNA            Tet1 KD mouse ES cells
GSM659783 Tet1 KD + Nanog overexpression (OE), rep1  RNA Tet1 KD + Nanog OE mouse ES cells
GSM659784 Tet1 KD + Nanog overexpression (OE), rep2  RNA Tet1 KD + Nanog OE mouse ES cells
GSM659785 Tet1 KD + Nanog overexpression (OE), rep3  RNA Tet1 KD + Nanog OE mouse ES cells
GSM659786 Tet1 KD + Nanog overexpression (OE), rep4  RNA Tet1 KD + Nanog OE mouse ES cells


I am only interested in gene expression change after Tet1 Knock down, so I set coef =1 in the command ( or you can specify a vector c(1,2,3) to look at comparisons among all three groups)

topgenes<- topTable(fit2, coef=1,number=2000, p.value=0.23, lfc=0.6, adjust="BH")

The original paper claims that there are total 1332 genes that are differentially expressed (788 upregulated and 544 downregulated in Tet1 KD cells) with FDR=0.05 ( they used another bioconductor package called NIA array analysis tool.  I am not sure what are the fold changesfor those genes). However, I only found 610 probes ( less genes, some genes have multiple probes) are differentially expressed with adjusted p.value = 0.05 ( the p.value argument in the above command is  actually the adjust p.value which is similar with the FDR) and a minimal fold change of 1.5 ( log fold change = 0.6, 2^0.6 = 1.51).

Nevertheless, I went on and sanity checked my gene list. It is a Tet1 KD experiment, so Tet1 should be downregulated.

head(topgenes)
                       ID Symbol     logFC   AveExpr         t      P.Value    adj.P.Val        B
1425532_a_at 1425532_a_at   Bin1  1.481071  7.455563  12.40969 1.996707e-08 0.0009005347 9.103139
1429448_s_at 1429448_s_at   Tet1 -2.246819 10.157653 -11.13936 6.989828e-08 0.0010641629 8.115987
1434369_a_at 1434369_a_at  Cryab  3.615875  8.073085  11.12716 7.078532e-08 0.0010641629 8.105799
1455425_at     1455425_at   Tet1 -2.145540 11.007240 -10.83405 9.615218e-08 0.0010841398 7.856887
1452253_at     1452253_at  Crim1  1.629262  5.253925  10.40753 1.520152e-07 0.0010997147 7.479479
1450780_s_at 1450780_s_at  Hmga2  2.138363  9.856595  10.36264 1.596633e-07 0.0010997147 7.438677

It showed up in the top list. logFC is -2.24 and -2.14 for two probes, demonstrating a really good KD. p value and adjust p value are both very small. This result reassured the correctness of my analysis.

In figure 4c, the authors used several gene examples to show Ezh2 binding is impaired after Tet1 KD, but they did not show the RT-qPCR result ( or at least need to check the microarray data). Those genes are supposed to be upregulated after Tet1 KD.

Of all the 8 examples, Lhx2, Eomes, Cdx2 did not show up in my gene list (even after I set the adjust p.value to 0.4). The others- Cyr61, Hoxa1, Sox17, Pcdh8, Gata6 are all upregulated in my list with relatively big adjust p value (0.1).
                     ID Symbol     logFC   AveExpr         t      P.Value    adj.P.Val        B

1457823_at     1457823_at  Cyr61 0.8698561 5.751129 3.763281 2.498490e-03 0.097058042 -1.4601779
1420565_at     1420565_at  Hoxa1 0.9393792   8.349 3.755187 0.002536592   0.09759434 -1.474719
1421657_a_at 1421657_a_at  Sox17 1.383838 6.663369 4.282790 9.577202e-04 0.057282062 -0.5375835
1447825_x_at 1447825_x_at  Pcdh8 1.388784 7.709455 3.422685 0.004741331    0.1354996 -2.074440
1417051_at     1417051_at  Pcdh8 1.480749 7.636717 3.380923 0.005131004    0.1412807 -2.149954
1425463_at 1425463_at  Gata6 0.8957893 6.507380 3.872267 0.0020389307    0.08715337 -1.2648024
It is not surprising that Tet1 maintains the expression of a group of active genes by keeping the promoters hypomethylated. Interestingly, Tet1 also maintains hypomethlyation state of bivalent gene promoters that favours PRC2, a silencing complex, to bind to theses promoters. Consequently, Tet1 contributes to the repression of Polycomb-targeted genes.
With this take home message in mind, I have several questions concerning the paper:
1. in figure 4, the authors showed several example genes that are repressed by Tet1. Are all these genes are bivalent? The authors only showed a H3k27Me3 track in figure 4b. I would at least do a ChIP-qPCR to confirm H3k4me3 and H3k27me3 occupancy at these promoters.
2. what is the exact mechanism that Tet1 represses gene expression?
The authors provided an explanation that Tet1-mediated hypomethylation is required for PRC2 silencing complex recruitment at bivalent promoters ( at least in figure 4c, the primers for Ezh2 ChIP-qPCR located at promoters). However, many shaded regions are in gene bodies. Note that the scale of the genomic regions is big. A close inspection reveals that Lhx2, Cyr61, Hoxa1, Pcdh8 gained DNA methylation in the gene bodies. It partially explains the upregulation of the gene expression after Tet1 KD (DNA methlyation in the gene body positively correlates with active gene expression). Do H3k27me3 occupancies decrease at these promoters? A ChIP-qPCR in Tet1 KD cells and control cells will answer this question.
In contrast, Eomes, Sox17 and Gata6 gained DNA methylation at promoters which may prevent the PRC2 binding and thus increase the expression. Do these genes also loss H3k27me3? It is still hard for me to believe that gain of DNA methylation at promoters can increase the gene expression. Histone modifications are more reversible, but DNA methylation is hard to reverse and is considered as a late stage of tumor suppressor silencing during tumor progression.
A quick google I found this http://epigenie.com/dna-methylation-in-gene-activation-with-dr-robert-waterland/
3'CpG island methlyation activates gene expression by interfering  enhancer blocking activity mediated by CTCF, an insulator protein that blocks enhancers from activating unintended targets. I worked on CTCF for a while, and knew  that DNA methylation abolishes CTCF binding at Igf2/H19 imprinting control region. It makes sense that 3'CpG methylation can enhancer gene expression by disrupting CTCF binding, thus allows 3' enhancers to induce the gene expression. Same rationale could be applied to 5'CpG island though. 5' enhancers are made accessible if the 5'CpG island is methylated resulting in a diminished CTCF binding at promoter region. Collectively, It is context dependent that whether DNA methylation can increase or decrease gene expression.   
Apparently, we have not  fully understood the function of DNA methylation, although it is commonly thought to contribute to gene silencing. However, we often find exceptions in biology, and  the exceptions lead to good papers if you have enough evidence to support. That's the beauty of science.

3. For heatmap in figure 3c, DNA methlyation data did not plot together with the histone modification profile and gene expression profile. Ideally, the Tet1-activated targets gain DNA methlyation at promoters after Tet1 KD, but I guess the pattern did not look good (see point 2, many are gained at gene bodies). There are many reasons for that. one of the reasons is that the upregulation of these group of genes are indirect effect of Tet1 KD, although the Tet1 ChIP-seq showed binding at promoters. It will be interesting to examine where the gain of DNA methylation occur at the Tet1-activated targets and where the loss of DNA methylation occur at the Tet1-repressed targets in terms of promoters or gene bodies ( I bet the authors have done that).
Several other genes mentioned in the paper:
                      ID Symbol    logFC  AveExpr        t      P.Value   adj.P.Val        B
1423691_x_at 1423691_x_at   Krt8 3.163397 10.06588 8.237845 2.023202e-06 0.002343863 5.243374
1435989_x_at 1435989_x_at   Krt8 2.655900 10.08545 7.189101 8.477813e-06 0.004726375 3.942816
1420647_a_at 1420647_a_at   Krt8 2.956087 10.54748 7.154126 8.913416e-06 0.004902488 3.896674
1421657_a_at 1421657_a_at  Sox17 1.383838 6.663369 4.282790 9.577202e-04 0.057282062 -0.5375835
1429388_at 1429388_at  Nanog -1.381565 12.00124 -3.010861 0.01035011 0.2014412 -2.817704
1441921_x_at 1441921_x_at  Esrrb -1.00944 9.764298 -3.406862 0.004885327 0.1374205 -2.103051
1422458_at 1422458_at   Tcl1 -1.30934 10.30728 -2.86801 0.01356834 0.2250628 -3.073405
Note that Nanog and Tcl1 have relatively big adjust p value (~0.2). A  false discovery rate of 0.2 means in 100 genes, there are 20 will be false positives.
Reading this post on Biostar http://www.biostars.org/p/18470/  cleared some of my doubts on FDR choosing. The bottom line is that there is no "right" cut-off for FDR. As long as the result make biological sense, we can play around with it.
In my analysis, I set the FDR to 0.23 to include Nanog and Tcl1. I have total 1292 (1067/1332 have a Tet1 binding within 5kb up- or down-stream of TSS in the paper ) unique genes that are differentially expressed which is pretty close to the original paper. Among them, 828 (677 in the paper)  are upregulated while 464(390 in the paper) are downregulated. This is consistent with the paper: more Tet1 targets are upregulated rather than downregulated with Tet1 depletion. I will need to work on the Tet1 ChIP-seq data to determine the exact number.

tommy@tommy-ThinkPad-T420:~/Tet1$ cat  topgenes_Fdr_0.23.txt | cut -f 3 | sort | uniq | grep -v "NA" | wc -l
1292
tommy@tommy-ThinkPad-T420:~/Tet1$ cat  topgenes_Fdr_0.23.txt | grep -v "NA" > topgenes_Fdr_0.23_no_NA.txt
tommy@tommy-ThinkPad-T420:~/Tet1$ cat topgenes_Fdr_0.23_no_NA.txt | cut -f 3,4 | awk '!a[$1]++' | awk '{if($2>0) a++; else b++} END{ print a,b}' 828 464
Look at the distribution of the p value and adjust p values.
> hist(topgenes$adj.P.Val)
> hist(topgenes$P.Val)
P values are all very small. 
For downstream analysis, read this post from Stephen Turner: http://gettinggeneticsdone.blogspot.com/2012/03/pathway-analysis-for-high-throughput.html
Conclusions:
1. It is a successful Tet1 KD experiment with a very good Tet1 KD and many differentially expressed genes.
2. There is no "right" way to analyze the data. Analyzing the same data by different people and different software may give different results, and it is not surprising to me. Actually, for the RNA-seq analysis, many different tools are developed ( most famous ones are cuff-diff, DESeq), and they all give different list of differentially expressed genes.  See papers here:
http://genomebiology.com/2013/14/9/R95
http://www.biomedcentral.com/1471-2105/14/91
Thus, it is critical to provide the raw code, the parameters and the software version etc to ensure a reproducible research. 
3. conclusions drawn from the global analysis tend to be "exaggerated", many patterns we observe are  only true for a sub set of data sets, and if we combine all the things together, the patterns conflict each other somehow. That's why when we come down to several genes to verify and those are the best examples ( I saw many global Genomic study papers use examples with "weird" gene names).  
These are my little thoughts, and I am happy to discuss with the authors.

Tuesday, December 3, 2013

explain shell

I just got to know this website from twitter explain shell
It is very useful, especially when I have a complex linux command and can not figure out what
does each flag mean.

For example:  du -h -d 1 ~

This command is very useful to check the folder sizes.
you can sort the folder by size:

tommy@tommy-ThinkPad-T420:~$ du -h -d 1 | sort -hr
63G .
16G ./homer
14G ./Desktop
13G ./Downloads
3.3G ./MochiView_v1.46
1.9G ./anaconda
1.2G ./scientific_writing
1022M ./.cache
938M ./SeqMonk
845M ./mochi_view
625M ./jorg_bungert
587M ./.thunderbird
400M ./.local
379M ./R
331M ./Datasets
257M ./gatk-protected
........

Thursday, November 21, 2013

mysql to get all the disease associated SNPs

I want to find SNPs occur at the transcription binding sites which may potentially affect the binding of the transcription factor.

I need  to have a list of SNPs that are associated with diseases first.
people usually go to dbSNP http://www.ncbi.nlm.nih.gov/SNP/
but the UCSC snp138 table hg19 is much better accessible in terms of parsing.

See posts here: http://www.biostars.org/p/1288/
http://www.biostars.org/p/7073/
http://www.biostars.org/p/11701/

find SNPs associated with OMIM gene  (by Pierre )
" Inspired by Khader's comment. The following mysql query for the mysql anonymous server at UCSC answers the SNPs in the OMIM genes:
mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A  -D hg18 -e '
select
   concat(left(title1,30),"..."),
   omimId,
   S.name,
   S.func,
   G.chrom,
   S.chromStart,
   S.chromEnd
from
   omimGene as G,
   omimGeneMap as M,
   snp130 as S
where
  G.name=M.omimId and
  G.chrom=S.chrom and
  S.chromStart>=G.chromStart and
  S.chromEnd <= G.chromEnd
limit 10;'
Result:
+-----------------------------------+--------+------------+--------------------+-------+------------+----------+
| concat(left(title1,30),"...")     | omimId | name       | func               | chrom | chromStart | chromEnd |
+-----------------------------------+--------+------------+--------------------+-------+------------+----------+
| Nucleolar complex-associated p... | 610770 | rs72904505 | untranslated-3     | chr1  |     869480 |   869481 |
| Nucleolar complex-associated p... | 610770 | rs6605067  | untranslated-3     | chr1  |     869538 |   869539 |
| Nucleolar complex-associated p... | 610770 | rs2839     | untranslated-3     | chr1  |     869549 |   869550 |
| Nucleolar complex-associated p... | 610770 | rs3196153  | untranslated-3     | chr1  |     869586 |   869587 |
| Nucleolar complex-associated p... | 610770 | rs1133980  | untranslated-3     | chr1  |     869614 |   869615 |
| Nucleolar complex-associated p... | 610770 | rs28453979 | untranslated-3     | chr1  |     869781 |   869782 |
| Nucleolar complex-associated p... | 610770 | rs61551591 | intron,near-gene-3 | chr1  |     870079 |   870080 |
| Nucleolar complex-associated p... | 610770 | rs3748592  | intron,near-gene-3 | chr1  |     870100 |   870101 |
| Nucleolar complex-associated p... | 610770 | rs3748593  | intron,near-gene-3 | chr1  |     870252 |   870253 |
| Nucleolar complex-associated p... | 610770 | rs74047418 | missense           | chr1  |     870364 |   870365 |
+-----------------------------------+--------+------------+--------------------+-------+------------+----------+
however the table is not available any more in the UCSC databases.
instead you should do:
also  by Pierre 
1) Register an access to the FTP site of omim: http://omim.org/downloads and download mim2gene:
$ curl -s  "ftp://anonymous:xxxxxxx@xxxxx.edu/OMIM/mim2gene.txt" | head
# Mim Number    Type    Gene IDs    Approved Gene Symbols
100050  phenotype   -   -
100070  phenotype   100329167   -
100100  phenotype   -   -
100200  phenotype   -   -
100300  phenotype   100188340   -
100500  moved/removed   -   -
100600  phenotype   -   -
100640  gene    216 ALDH1A1
100650  gene/phenotype  217 ALDH2
get a list of the gene symbols:
~$ curl -s  "ftp://anonymous:xxxxx@xxxxxx.edu/OMIM/mim2gene.txt" |\
   egrep -v "#" | cut -d '  ' -f 4 | egrep -v '^\-$' |\
   sort | uniq > list1.txt
2) get your list of SNP associiated to the gene symbol. Something like:
mysql -N --user=genome --host=genome-mysql.cse.ucsc.edu -A  -D hg19 -e 'select  distinct
  G.geneSymbol,
  S.name
from snp132 as S,
kgXref as G,
knownGene as K where
    S.chrom=K.chrom and
    S.chromStart>=K.txStart and
    S.chromEnd<=K.txEnd and
    K.name=G.kgId 
    /* AND something to restrict the result to YOUR list of SNPs or gene */
' | sort -t '    ' -k1,1 > list2.txt
3) use unix join to join the two lists:
join -1 1 -2 1 list1.txt list2.txt
you should get a list with two columns: the OMIM gene and your SNP.


I want to get a list of SNPs that are clinical associated. description of the snp138 table
http://genome.ucsc.edu/cgi-bin/hgTables
at terminal:

mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -D hg19 -e ' SELECT * FROM snp138 AS s WHERE s.bitfields LIKE  "clin%" ' > clinic_associated_SNPs_hg19.txt

remember you are on the remote server of UCSC, you can not connect the database first, and do something like:

SELECT *
FROM snp138 AS s

WHERE s.bitfields LIKE "clin%"
INTO OUTFILE '/home/tommy/clinic_associated_SNPs_hg.txt'
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n';


Because we do not have the write privilege
after I got the txt file, I  changed it to a bed file:

tommy@tommy-ThinkPad-T420:~$ cat clinic_associated_SNPs_hg19.txt | cut -f2-7 | head
chrom chromStart chromEnd name score strand
chr1 985954 985955 rs199476396 0 +
chr1 1199488 1199489 rs207460006 0 +
chr1 1245103 1245104 rs144003672 0 +
chr1 1265153 1265154 rs307355 0 +
chr1 1265459 1265460 rs35744813 0 -
chr1 1469330 1469331 rs145324009 0 +
chr1 1635334 1635335 rs201004006 0 +
chr1 1689555 1689556 rs207460007 0 +
chr1 1959074 1959075 rs121434580 0 +

tommy@tommy-ThinkPad-T420:~$ wc -l clinic_associated_SNPs_hg19.txt 
103174 clinic_associated_SNPs_hg19.txt

There are total 103174 SNPs in the file.
Now, I can just use bedtools to intersect the SNPs bed file with the ChIP-seq bed file generated by MACS.

tommy@tommy-ThinkPad-T420:~$ bedtools intersect -a TF.bed -b SNPs_hg19.bed -wo 

Just keep in mind the difference between the 0 based and 1 based coordinates system. See a post here:

Alternatively, you can create a database to do this kind of intersection by using Join command.

other tools

Finally a python package for Database https://dataset.readthedocs.org/en/latest/quickstart.html

Tuesday, November 19, 2013

mysql rocks

I just finished the first chapter of MySQL by Paul DuBois http://www.amazon.com/MySQL-5th-Edition-Developers-Library-ebook/dp/B00C2SFK2Q
I was really excited to explore the power of mysql. Just by following the command examples of  the two sample databases in the book, I learned a lot.

I am studying biology, so, I want to make practical use of mysql. One of the databases on top of my mind is the UCSC genome browser database http://genome.ucsc.edu/goldenPath/help/mysql.html

connect to the database:
tommy@tommy-ThinkPad-T420:~$ mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ailMel1            |
| allMis1            |
| anoCar1            |
| anoCar2            |
| anoGam1            |
| apiMel1            |
............................
............................
mysql> use hg19
Database changed

find the hg19 refGene annotation table

mysql> show tables like "%ref%";
+------------------------+
| Tables_in_hg19 (%ref%) |
+------------------------+
| kgXref                 |
| kgXrefOld5             |
| kgXrefOld6             |
| refFlat                |
| refGene                |
| refLink                |
| refSeqAli              |
| refSeqStatus           |
| refSeqSummary          |
+------------------------+
9 rows in set (0.12 sec)

mysql> describe refGene;  
+--------------+------------------------------------+------+-----+---------+-------+
| Field        | Type                               | Null | Key | Default | Extra |
+--------------+------------------------------------+------+-----+---------+-------+
| bin          | smallint(5) unsigned               | NO   |     | NULL    |       |
| name         | varchar(255)                       | NO   | MUL | NULL    |       |
| chrom        | varchar(255)                       | NO   | MUL | NULL    |       |
| strand       | char(1)                            | NO   |     | NULL    |       |
| txStart      | int(10) unsigned                   | NO   |     | NULL    |       |
| txEnd        | int(10) unsigned                   | NO   |     | NULL    |       |
| cdsStart     | int(10) unsigned                   | NO   |     | NULL    |       |
| cdsEnd       | int(10) unsigned                   | NO   |     | NULL    |       |
| exonCount    | int(10) unsigned                   | NO   |     | NULL    |       |
| exonStarts   | longblob                           | NO   |     | NULL    |       |
| exonEnds     | longblob                           | NO   |     | NULL    |       |
| score        | int(11)                            | YES  |     | NULL    |       |
| name2        | varchar(255)                       | NO   | MUL | NULL    |       |
| cdsStartStat | enum('none','unk','incmpl','cmpl') | NO   |     | NULL    |       |
| cdsEndStat   | enum('none','unk','incmpl','cmpl') | NO   |     | NULL    |       |
| exonFrames   | longblob                           | NO   |     | NULL    |       |
+--------------+------------------------------------+------+-----+---------+-------+
16 rows in set (0.54 sec)

which gene has the most exons?

mysql> select chrom, name, name2, exonCount from refGene order by exonCount DESC limit 10;
+-------+--------------+-------+-----------+
| chrom | name         | name2 | exonCount |
+-------+--------------+-------+-----------+
| chr2  | NM_001267550 | TTN   |       363 |
| chr2  | NM_001256850 | TTN   |       313 |
| chr2  | NM_133378    | TTN   |       312 |
| chr2  | NM_133437    | TTN   |       192 |
| chr2  | NM_133432    | TTN   |       192 |
| chr2  | NM_003319    | TTN   |       191 |
| chr2  | NM_001271208 | NEB   |       183 |
| chr2  | NM_001164507 | NEB   |       182 |
| chr2  | NM_001164508 | NEB   |       182 |
| chr12 | NM_173600    | MUC19 |       173 |
+-------+--------------+-------+-----------+

I want the genes rather than the transcripts, so I group them by gene name (name2)


mysql> select chrom, name, name2, max(exonCount) AS maximum from refGene group by name2 order by maximum DESC limit 10;
+-------+--------------+--------------+---------+
| chrom | name         | name2        | maximum |
+-------+--------------+--------------+---------+
| chr2  | NM_001256850 | TTN          |     363 |
| chr2  | NM_001271208 | NEB          |     183 |
| chr12 | NM_173600    | MUC19        |     173 |
| chr6  | NM_033071    | SYNE1        |     146 |
| chr1  | NM_001278267 | LOC100288142 |     131 |
| chr3  | NM_000094    | COL7A1       |     118 |
| chr14 | NM_182914    | SYNE2        |     116 |
| chr1  | NM_001098623 | OBSCN        |     116 |
| chr7  | NM_198455    | SSPO         |     110 |
| chr1  | NM_031935    | HMCN1        |     107 |
+-------+--------------+--------------+---------+
10 rows in set (2.53 sec)
sanity check on UCSC genome browser:


Just curious, which gene has the longest transcript?

mysql> select chrom, name, name2, txEnd-txStart AS span  from refGene  order by span  DESC limit 10;
+-------+--------------+--------------+---------+
| chrom | name         | name2        | span    |
+-------+--------------+--------------+---------+
| chr1  | NM_001278267 | LOC100288142 | 2320934 |
| chr7  | NM_014141    | CNTNAP2      | 2304636 |
| chr9  | NM_002839    | PTPRD        | 2298478 |
| chrX  | NM_000109    | DMD          | 2220382 |
| chr11 | NM_001142699 | DLG2         | 2172259 |
| chrX  | NM_004006    | DMD          | 2092329 |
| chr8  | NM_033225    | CSMD1        | 2059454 |
| chr20 | NM_080676    | MACROD2      | 2057696 |
| chrX  | NM_004009    | DMD          | 2009201 |
| chrX  | NM_004010    | DMD          | 2009200 |
+-------+--------------+--------------+---------+
10 rows in set (0.40 sec)



These two genes span more than 2Mb!

of course, one can download the refGene table to local computer and use awk  etc to do this kind of work, but I just see how powerful and convenient mysql is especially when you have multiple tables and want to do some summarization across them.

Saturday, November 16, 2013

ChIP-exo data analysis

Our neighboring lab just generated some ChIP-exo data, (if you do not know the technique, look at this paper http://www.ncbi.nlm.nih.gov/pubmed/23026909) and the company did some analysis but not what they want. The bedgraph files generated by the company were separated for plus strand and minus strand. They want just peak files like in the ChIP-seq experiment.

I was aware of several software can be used to deal with this type of data:
Tao Liu's MACS https://github.com/taoliu/MACS/
this is probably the most widely used method for ChIP-seq peak calling, and it is also suitable for ChIP-exo data
https://github.com/taoliu/MACS/issues/15

Peakzilla https://github.com/steinmann/peakzilla
A new tool for ChIP-exo

"Peakzilla identifies sites of enrichment and transcription factor binding sites from transcription factor ChIP-seq and ChIP-exo experiments at hight accuracy and resolution. It is designed to perform equally well for data from any species. All necessary parameters are estimated from the data. Peakzilla is suitable for both single and paired end data from any sequencing platform."

A quick google I found several others:
MACE http://chipexo.sourceforge.net/
and GEM http://www.psrg.csail.mit.edu/gem/

Since MACS (version 1.4) was pre-installed in the HPC at UFL, I decided to give it a try

[mtang@dev1 mm10]$ module load macs

macs -t ChIP.bam -c control.bam -f BAM -g mm -n ChIP-exo -B

it took some time to finish the process (~30mins).  with -B flag, I want to output the bedgraph files for each chromosomes. If you specify -S, it will give you a single bedgraph file for the whole genome.

Look at the model built by MACS


You can have a quick look at the data by loading the bedgraph files into IGV. I just pick VEGFa to check




The peaks look very specific and sharp.

Then, I can find all the genes that contain a peak nearby.
Homer annotatePeaks http://biowhat.ucsd.edu/homer/ngs/annotation.html
if you use R, ChIPpeakAnno http://www.ncbi.nlm.nih.gov/pubmed/20459804
cistrome can do it very easily http://cistrome.org

BETA-minus: Targets prediction with binding only Predict the factors (TFs or CRs) direct target genes by only binding data
CEAS http://liulab.dfci.harvard.edu/CEAS/  also from Liu's lab
the easiest way PAVIS http://manticore.niehs.nih.gov:8080/pavis/

Monday, November 11, 2013

So you want to be a computational biologist?

See a commentary here : http://www.nature.com/nbt/journal/v31/n11/abs/nbt.2740.html

Quotes from the article:
“Laboratory scientists wouldn’t
dream of running experiments
without the necessary positive
and negative controls... tests
are the computational biology
equivalent.”

“Knowledge of biology is
vital in the interpretation of
computational results.”


Learning resources:




Friday, November 1, 2013

DESeq work flow

I was working on a human RNA-seq data set, and I already got the count matrix by HTSeq.
see my previous post here http://crazyhottommy.blogspot.com/2013/10/rna-seq-analysis-samtools-sort-and.html

Now, I am ready to use DESeq to detect the differentially expressed genes.
I followed the nature protocol from Simon Anders and here http://dwheelerau.com/2013/04/15/how-to-use-deseq-to-analyse-rnaseq-data/
for more details read the DESeq manual.



several out put
> head(countsTable)
          a1  b1  a2 b2  a3 b3
0R7H2P    21   9   3  6   1  4
5S_rRNA   55  87  56 56  34 40
7SK      171  89  61 84  57 47
A1BG      15  34  38 10  12 23
A1BG-AS1  65  49 140 41  40 44
A1CF     293 109 417 90 181 84

> head(counts(cds,normalized=TRUE))
                a1        b1         a2        b2         a3
0R7H2P    14.44370  7.348284   2.360913  5.935807   1.583712
5S_rRNA   37.82875 71.033416  44.070367 55.400869  53.846220
7SK      117.61301 72.666368  48.005221 83.101303  90.271605
A1BG      10.31693 27.760186  29.904892  9.893012  19.004548
A1BG-AS1  44.70670 40.007326 110.175917 40.561350  63.348494
A1CF     201.52404 88.995889 328.166838 89.037110 286.651937
                 b3
0R7H2P     5.492968
5S_rRNA   54.929684
7SK       64.542378
A1BG      31.584568
A1BG-AS1  60.422652
A1CF     115.352336
dispersion plot


MAplot: there are not many genes that are differentially expressed. Usually you should see red dots around the edge of the cloud. 








pvalue histogram, there are not many genes with a low p-value, usually you see a spike near x=0




PCA plot. PCA does not look great, one replicate for each cell type varies too much with the other two replicates, and it looks the same situation from the original PCA figure in the paper below.


figure2 from the original paper http://www.jci.org/articles/view/66514/figure/2




differentially expressed genes  according to figure 2 ( I read the supplement material, those genes are with more than 2 fold changes)

alpha cell specific: IRX2, PCSK2, DPP4,IRX1,GCG, PTPRD, ARX, HNF1A
beta cell specific: MAFA, GLP1R, PCSK1, PDX1, NKX6-1, CDKN1C, KCNQ2, INS, SLC30A8, HDAC9, IAPP, KCNJ11
My DESeq results:
> resSig[resSig$id=="GCG",]
       id baseMean baseMeanA baseMeanB foldChange log2FoldChange        pval padj
15096 GCG 127322.8  245014.6  9630.952 0.03930766      -4.669046 0.008959299    1
similarly I got others:
25252 PCSK2 1605.296  2448.875  761.7172  0.3110478      -1.684792 0.01701203    1
17931 IRX2 437.8337  764.6114  111.0561  0.1452451      -2.783438  0.00364283    1       
12803 DPP4  418.095  755.6109  80.57906  0.1066409      -3.229167  0.01849249    1
6374 ARX  104.137  166.6132  41.66077  0.2500449        -1.999741  0.01581663    1
        id baseMean baseMeanA baseMeanB foldChange log2FoldChange        pval padj
20260 MAFA 802.9027  156.4095  1449.396   9.266673       3.212052  0.04860831    1
15303 GLP1R 265.7284  172.2726  359.1841   2.084975        1.06003 0.05890757    1
25250 PCSK1 6597.262  2279.658  10914.87   4.787941       2.259405 0.09637812    1
8682 CDKN1C 581.1144  198.1623  964.0666   4.865035       2.28245 0.009237992    1
18299 KCNQ2 141.9849   86.3116  197.6583   2.290055       1.195382  0.0422248    1
17827 INS 7444.435  1668.456  13220.41    7.92374       2.986181  0.002803966    1
16172 HDAC9 527.0126   260.651  793.3742   3.043818      1.605882 0.004025324    1
17099 IAPP 6943.366  2072.604  11814.13   5.700136       2.510996  0.06844496    1
I only missed IRX1,PTPRD and HNF1A in alpha cells
and missed PDX1, SLC30A8 and KCNJ11 in beta cells.
> res[res$id=="IRX1",]
        id baseMean baseMeanA baseMeanB foldChange log2FoldChange  pval padj

17929 IRX1 115.7047  134.3566  97.05282  0.7223525      -0.469225 0.4556522    1

I checked the other missed ones, they are all with big p-values.  I do note that the P-adj values are all very big, that may due to the big variation among the replicates. The original paper used the FPKM rather than raw counts to detect the differentially expressed genes. However, considering the large overlapping gene list, I am pretty satisfied with my analysis. further reading counts VS FPKM http://www.cureffi.org/2013/09/12/counts-vs-fpkms-in-rna-seq/.I may try to use cuffdiff to do the same analysis some time later.
Alternatively, you can upload your raw count matrix to DEG-Vis http://www.vicbioinformatics.com/dge-vis/index.html to perform similar analysis without the knowledge of R. DEG-Vis uses EdgeR and limma internally.