--- title: "01-Pmeandrina-lncRNA-discovery" author: "Zach Bengtsson" date: "2023-08-16" output: html_document --- dddd ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` # lncRNA Discovery for Pocillopora meandrina ## HISAT HISAT2 build to create an index for the FASTA file... ```{bash hisat-build} #FASTA file path input ref_genome="/home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/data/Pocillopora_meandrina_HIv1.assembly.fasta" index="/home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/Pmea/Pmea.index" /home/shared/hisat2-2.2.1/hisat2-build \ -f "$ref_genome" \ "$index" ``` HISAT2 to align paired-end RNA-Seq reads to the index... ```{bash} find /home/shared/8TB_HDD_01/pmea/trimmed/*gz \ | xargs basename -s _R1_001.fastp-trim.20230519.fastq.gz | xargs -I{} \ /home/shared/hisat2-2.2.1/hisat2 \ -x /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/Pmea/Pmea.index \ -p 20 \ -1 /home/shared/8TB_HDD_01/pmea/trimmed/{}_R1_001.fastp-trim.20230519.fastq.gz \ -2 /home/shared/8TB_HDD_01/pmea/trimmed/{}_R2_001.fastp-trim.20230519.fastq.gz \ -S /home/shared/8TB_HDD_01/pmea/sam/{}.sam ``` ## Samtools Samtools to convert the SAM files output from the previous HISAT2 command into sorted BAM files... ```{bash samtools} for file in /home/shared/8TB_HDD_01/pmea/sam/*.sam; do base=$(basename "$file" .sam) /home/shared/samtools-1.12/samtools view -bS "$file" | \ /home/shared/samtools-1.12/samtools sort \ -o /home/shared/8TB_HDD_01/pmea/bam/"$base".bam done ``` ## StringTie StringTie to assemble transcripts from the sorted BAM files generated by the previous Samtools commands... ```{bash stringtie} find /home/shared/8TB_HDD_01/pmea/bam/*bam \ | xargs basename -s .bam | xargs -I{} \ /home/shared/stringtie-2.2.1.Linux_x86_64/stringtie \ -p 8 \ -G ../data/Pocillopora_meandrina_HIv1.genes.gff3 \ -o /home/shared/8TB_HDD_01/pmea/stringtie-assembly/{}.gtf \ /home/shared/8TB_HDD_01/pmea/bam/{}.bam \ ``` Use StringTie merge to merge all the individual GTF files into a single merged GTF file... ```{bash stringtie} /home/shared/stringtie-2.2.1.Linux_x86_64/stringtie \ --merge \ -G ../data/Pocillopora_meandrina_HIv1.genes.gff3 \ -o /home/shared/8TB_HDD_01/pmea/merged-gtf/pmea_stringtie_merged.gtf \ /home/shared/8TB_HDD_01/pmea/stringtie-assembly/*.gtf ``` ```{bash} head /home/shared/8TB_HDD_01/pmea/merged-gtf/pmea_stringtie_merged.gtf tail /home/shared/8TB_HDD_01/pmea/merged-gtf/pmea_stringtie_merged.gtf ``` ## GFFcompare Use gffcompare to compare annotation file generated by StringTie to a reference annotation file and to produce a set of output files summarizing the results of the comparison, including classification of each transcript... ```{bash gffcompare} /home/shared/gffcompare-0.12.6.Linux_x86_64/gffcompare \ -r ../data/Pocillopora_meandrina_HIv1.genes.gff3 \ -G ../data/Pocillopora_meandrina_HIv1.genes.gff3 \ -o /home/shared/8TB_HDD_01/pmea/gffcompare/pmea_gffcompare_merged \ /home/shared/8TB_HDD_01/pmea/merged-gtf/pmea_stringtie_merged.gtf \ ``` ```{bash} head /home/shared/8TB_HDD_01/pmea/gffcompare/pmea_gffcompare_merged.combined.gtf ``` ## Filter Filter to get a subset of the transcripts from the original GTF file that are putative lncRNA candidates based on their length and lack of overlap with known reference transcripts… ```{bash filter} awk '$3 == "transcript" && $1 !~ /^#/ {print}' /home/shared/8TB_HDD_01/pmea/gffcompare/pmea_gffcompare_merged.combined.gtf | grep 'class_code "u"' | awk '$5 - $4 > 199 {print}' > /home/shared/8TB_HDD_01/pmea/filter-one/pmea_merged_lncRNA_candidates.gtf ``` ```{bash} head /home/shared/8TB_HDD_01/pmea/filter-one/pmea_merged_lncRNA_candidates.gtf ``` ## Bedtools Get fasta of lncRNA candidate regions with Bedtools… ```{bash bedtools} /home/shared/bedtools2/bin/bedtools \ getfasta -fi /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/data/Pocillopora_meandrina_HIv1.assembly.fasta -bed /home/shared/8TB_HDD_01/pmea/filter-one/pmea_merged_lncRNA_candidates.gtf -fo /home/shared/8TB_HDD_01/pmea/get-fasta/pmea_merged_lncRNA_candidates.fasta -name -split ``` ```{bash} head /home/shared/8TB_HDD_01/pmea/get-fasta/pmea_merged_lncRNA_candidates.fasta ``` ## CPC2 Evaluate coding potential of transcripts with Coding Potential Calculator 2… ```{bash} eval "$(/opt/anaconda/anaconda3/bin/conda shell.bash hook)" python /home/shared/CPC2_standalone-1.0.1/bin/CPC2.py -i /home/shared/8TB_HDD_01/pmea/get-fasta/pmea_merged_lncRNA_candidates.fasta -o ~/github/coral-lncRNA/ouput/pmea_merged_cpc2_results ``` ## Final Filter Filter for those transcripts with label “noncoding”… ```{bash} # Filter out transcripts with coding potential awk '$8 == "noncoding" {print $1}' /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_merged_cpc2_results.txt > /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_noncoding_transcripts_ids.txt grep -Fwf /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_noncoding_transcripts_ids.txt /home/shared/8TB_HDD_01/pmea/get-fasta/pmea_merged_lncRNA_candidates.fasta > /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_merged_final_lncRNAs.gtf ``` ```{bash} head ~/github/coral-lncRNA/ouput/pmea_merged_final_lncRNAs.gtf tail ~/github/coral-lncRNA/ouput/pmea_merged_final_lncRNAs.gtf ``` ## Remove repeats of transcript IDs Get duplicate lines out of GTF file and save as new GTF... ```{bash} awk '!seen[$0]++' ~/github/coral-lncRNA/ouput/pmea_merged_final_lncRNAs.gtf > ~/github/coral-lncRNA/ouput/pmea_deduplicated_final_lncRNAs.gtf ``` ## Reformat GTF to BED Format GTF to BED file... ```{bash} awk -F":|-" '{print $3 "\t" $4 "\t" $5}' /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_deduplicated_final_lncRNAs.gtf > /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_deduplicated_final_lncRNAs.bed ``` ## BEDTools Use bedtools to get lncRNA fasta... ```{bash} /home/shared/bedtools2/bin/bedtools \ getfasta -fi /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/data/Pocillopora_meandrina_HIv1.assembly.fasta -bed /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_deduplicated_final_lncRNAs.bed -fo /home/shared/8TB_HDD_02/zbengt/github/coral-lncRNA/ouput/pmea_bedtools_lncRNAs.fasta -name ```