{"id":18246338,"url":"https://github.com/mfcovington/bis180l-rnaseq","last_synced_at":"2025-04-08T19:28:21.108Z","repository":{"id":16749369,"uuid":"19506964","full_name":"mfcovington/BIS180L-RNAseq","owner":"mfcovington","description":null,"archived":false,"fork":false,"pushed_at":"2014-05-06T19:34:59.000Z","size":25104,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T15:15:40.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfcovington.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-06T19:04:49.000Z","updated_at":"2014-09-09T18:16:51.000Z","dependencies_parsed_at":"2022-07-14T11:47:13.955Z","dependency_job_id":null,"html_url":"https://github.com/mfcovington/BIS180L-RNAseq","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2FBIS180L-RNAseq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2FBIS180L-RNAseq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2FBIS180L-RNAseq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfcovington%2FBIS180L-RNAseq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfcovington","download_url":"https://codeload.github.com/mfcovington/BIS180L-RNAseq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247912008,"owners_count":21016980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T09:25:31.800Z","updated_at":"2025-04-08T19:28:21.075Z","avatar_url":"https://github.com/mfcovington.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Module 1: Align Reads to Arabidopsis Genes and Determine Read Counts per Gene\n\n\nIn this module we will analyze Illumina gene expression data generated from a FASTQ file (`wt_mRNA_100K_reads.fq`). This data file contains a sampling of reads from RNA sequencing of wild-type seedlings. For your reference, please access the article that describes the age of these seedlings, their genotype, how they were treated, as well as for that of the pifq mutant. This information should be recorded in the Materials and Methods section of your lab report\n\nWe will use BWA to align this data to Arabidopsis genes. BWA is a fast and efficient short read aligner geared towards quickly aligning large sets of short DNA/RNA sequences (reads) to large genomes/transcriptomes. BWA takes an index and a set of reads as input and outputs a list of alignments in a SAM file SAM stands for 'Sequence Alignment/Map'.\n\nWe will use Samtools to access and manipulate the alignments and a Perl script to count the number of reads mapping to each gene.\n\n## Resources\n\nYou will need the following files. They are available on GitHub at \u003chttps://github.com/mfcovington/BIS180L-RNAseq\u003e.\n\n- cDNA and CDS (coding DNA sequence) FASTA reference files from TAIR (The Arabidopsis Information Resource)\n\n    - `TAIR10_cdna_20110103_representative_gene_model_updated.fa`\n    - `TAIR10_cds_20110103_representative_gene_model_updated.fa`\n\n- Sample FASTQ file to map to the FASTA files: `wt_mRNA_100K_reads.fq`\n\n- A Perl script to count the # of reads mapping to each gene: `bam2counts.pl`\n\n- A markdown version of these instructions is also available in the git repository: `README.md`\n\nDocumentation for tools used for mapping reads and visualizing alignments can be found online:\n\n- BWA: \u003chttp://bio-bwa.sourceforge.net/bwa.shtml\u003e\n- Samtools: \u003chttp://samtools.sourceforge.net/samtools.shtml\u003e\n\n## Exercises\n\n#### Mapping reads to an indexed reference\n\nFirst, we will index the FASTA reference file. This is required before we can map using `bwa`. Mapping requires a few steps. The first mapping step uses `bwa aln` to create a sequence alignment index. This `.sai` file is converted into a SAM file using `bwa samse` or `bwa sampe` depending on whether your FASTQ file contains single read or paired end data. SAM files can be further converted to BAM files (described below) using `samtools`.\n\nYou'll notice that we are assigning long file names and frequently used ID values to variables. This makes our code more readable, reusable, and typo-resistant. Be careful though. Variables will not be defined in other terminal windows. To confirm that the variable contains what you expect, you can check its contents with: `echo $VARIABLE_NAME`.\n\nBuild index of FASTA reference file before mapping:\n\n```sh\nFA=TAIR10_cdna_20110103_representative_gene_model_updated.fa\nbwa index $FA\n```\n\nMap reads in FASTQ file to FASTA reference:\n\n```sh\nID=wt_mRNA_100K_reads\nbwa aln $FA $ID.fq \u003e $ID.sai\nbwa samse $FA $ID.sai $ID.fq \u003e $ID.sam\nsamtools view -Sb $ID.sam \u003e $ID.bam\n```\n\n#### Visualizing SAM/BAM files\n\nSAM files are plain-text and can be visualized with commands such as `head` and `less`. BAM files contain all the information that the corresponding SAM file contains, but is significantly smaller in size. Since they are binary format, BAM files require a tool like `samtools` for visualization.\n\nThe following are equivalent (*note: `-S` turns off word wrap for `less`*):\n\n```sh\nless -S $ID.sam\nsamtools view -h $ID.bam | less -S\n```\n\nThese views start by listing every sequence ID from the FASTA reference file. Samtools lets you easily ignore this header (by leaving off the `-h` flag) and get right to the actual alignments.\n\n```sh\nsamtools view $ID.bam | less -S\n```\n\nYou'll see something like this:\n\n    SRR477075.1 4   *   0   0   *   *   0   0   NGAAACTTCTGATCGTCATGGAAGCTACTTCACAAC    #1:BDDEFDHFDFIGFHIIIIIIIBEHBEHBEHGGI\n    SRR477075.2 16  AT1G52300.1 114 25  36M *   0   0   TTACCCCGCCGCTCGCAAGAGGACTTACAACTGGAN    ####FIHEIIHHBIIIIIIIIIHHHGHHFFFDD=1#    XT:A:U  NM:i:2  X0:i:1  X1:i:0  XM:i:2  XO:i:0  XG:i:0  MD:Z:3T31G0\n    SRR477075.3 4   *   0   0   *   *   0   0   CCTCGTTCAAGTCAAGTTGTTGGATGGCCTCCTATA    @@@DFDDDHHHFHIGGHDHIGGIE\u003cG?EH+?GHEHE\n    SRR477075.4 16  AT2G38530.1 205 37  36M *   0   0   GACCGTCAGCAAGCTTGCCGTTGCCTTCAATCTGCC    D@FF?\u003cCJIGIGHBBIGHGIIJIHHHHHFFFDD@@@    XT:A:U  NM:i:0  X0:i:1  X1:i:0  XM:i:0  XO:i:0  XG:i:0  MD:Z:36\n    ...\n\nThere is a lot of information here. The SAM format is described in full in the Samtools documentation at \u003chttp://samtools.sourceforge.net/samtools.shtml#5\u003e; however, a few key facts about the SAM format will get you started:\n\n- Each read from the FASTQ file is represented by one line in the SAM/BAM file (The read ID is the 1st column)\n- The 3rd column indicates the reference sequence that the read maps (if the read fails to map, you will see a `*`)\n- The 4th column is the left-most position of the mapped read\n- The 5th column is the mapping quality (MAPQ; the higher the better)\n\n#### Counting number of reads mapped to each gene\n\nIn order to do differential gene expression analysis, we first need to know how many reads map to each gene.\n\nCount the number of reads mapping to each gene:\n\n```sh\nperl bam2counts.pl counts.tsv $ID.bam\n```\n\nLet's see what the output looks like:\n\n```sh\nhead counts.tsv\n```\n\n    wt_mRNA_100K_reads\n    AT1G01010.1 2\n    AT1G01020.1 4\n    AT1G01030.1 0\n    AT1G01040.2 7\n    AT1G01050.1 5\n    AT1G01060.1 2\n    AT1G01070.1 0\n    AT1G01073.1 0\n    AT1G01080.2 2\n\n#### Sorted BAM files\n\nIn order to be used to their full potential, BAM files need to be sorted and indexed. This allows the alignment information to be accessed much quicker and many downstream tools require an index (e.g., Integrated Genomics Viewer, [IGV](https://www.broadinstitute.org/igv/home)).\n\nSort \u0026 Index BAM file:\n\n```\nsamtools sort $ID.bam $ID.sorted\nsamtools index $ID.sorted.bam\n```\n\nLet's see how the sorted BAM file looks (compare this to how the unsorted BAM file looked above)\n\n```sh\nsamtools view $ID.sorted.bam | less -S\n```\n\n    SRR477075.7939  16  AT1G50920.1 50  37  36M *   0   0   AGTTCGTTGACATCATCCTTTCACGGACTCAGCGTC    FEIGBJJIJJGGCFEGJHGGEGBHFHHGFFFFF@@C    XT:A:U  NM:i:0  X0:i:1  X1:i:0  XM:i:0  XO:i:0  XG:i:0  MD:Z:36\n    SRR477075.42057 16  AT1G50920.1 96  37  36M *   0   0   TGTTGTCCACAAGGGTTACAAGATTAACCGTCTCCG    3;D3C:1:113CA?A:,A??\u003cEC48C0DDDD:B?;?    XT:A:U  NM:i:0  X0:i:1  X1:i:0  XM:i:0  XO:i:0  XG:i:0  MD:Z:36\n    SRR477075.51923 16  AT1G50920.1 130 37  36M *   0   0   CGTCAGTTCTCCATGAGAAAGGTTAAGTACACTCAG    EE@IEFEFC++B\u003cFIA+E\u003c\u003c@BF\u003eFB?DA22?A@??    XT:A:U  NM:i:1  X0:i:1  X1:i:0  XM:i:1  XO:i:0  XG:i:0  MD:Z:10A25\n    SRR477075.53014 0   AT1G50920.1 742 37  36M *   0   0   CGAGCTGCTGTTTTGTTCTTTCTCGACATTTCTGGA    CCBFFFFFHHHHHJJIIGJJJHIIHJJIIIJIIIII    XT:A:U  NM:i:0  X0:i:1  X1:i:0  XM:i:0  XO:i:0  XG:i:0  MD:Z:36\n    ...\n\n## Questions\n\n#### Question #1-1\n\nWhat are three pros/cons of SAM vs BAM format?\n\n#### Question #1-2\n\nHow does the TAIR10 CDS reference differ from the TAIR10 cDNA reference? How does the `bam2counts.pl` output for `AT1G20620.1` differ for CDS vs cDNA and why?\n\n#### Question #1-3\n\nMapping multiple FASTQ files and subsequent read counting can be automated as in this example:\n\n```sh\nFA=TAIR10_cdna_20110103_representative_gene_model_updated.fa\nfor ID in sample1 sample2 sample3 sample4; do\n    bwa index $FA\n    bwa aln $FA $ID.fq \u003e $ID.sai\n    bwa samse $FA $ID.sai $ID.fq \u003e $ID.sam\n    samtools view -Sb $ID.sam \u003e $ID.bam\ndone\nperl bam2counts.pl counts.tsv *.bam\n```\n\nWhat are at least two major advantages to such automation?\n\n#### Question #1-4\n\nThere are many different parameters/options available tools like `bwa` and `samtools`. How much does filtering out reads with lower mapping qualities (MAPQ) affect the # of reads mapped?\n\nThe command to remove mapped reads with MAPQ less than 20 is:\n\n`samtools view -Sb -q20 $ID.sam \u003e $ID.q20.bam`\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfcovington%2Fbis180l-rnaseq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfcovington%2Fbis180l-rnaseq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfcovington%2Fbis180l-rnaseq/lists"}