Requirements

Ensure that each of the software tools mentioned in this section (except Trinity) are available within your unix PATH setting. For example, if you have tools installed in a “/usr/local/tools” directory, you can update your PATH setting to include this directory in the search path by: % export PATH=/usr/local/tools:$PATH

Equipment Setup

Optionally, and only for simplicity, define the environmental variable TRINITY_HOME, replacing “/software/trinityrnaseq” below with the path to your Trinity software installation. Alternatively, write the full path where $TRINITY_HOME appears in the Procedure

% export TRINITY_HOME=/software/trinityrnaseq

Procedure

Collection of RNA-Seq data Timing: ~10 minutes===

  1. Download strand-specific RNA-Seq data from Schizosaccharomyces pombe grown in four conditions45 (logarithmic growth, plateau phase, diauxic shift, and heat shock, each with 1M Illumina paired-end strand-specific RNA-Seq data, to a total of 4M paired-end reads) by visiting the URL reported below in a web browser, or directly from the command line using ‘wget’:

    % wget http://sourceforge.net/projects/trinityrnaseq/files/misc/TrinityNatureProtocolTutorial.tgz/download
  2. Name the file thus downloaded ‘TrinityNatureProtocolTutorial.tgz’, which should be 540 MB in size.

  3. Unpack this file by:

    tar –xvf TrinityNatureProtocolTutorial.tgz

which should generate the following files in a TrinityNatureProtocolTutorial/ directory with the following contents:

S_pombe_refTrans.fasta   # reference transcriptome for S. pombe
1M_READS_sample/Sp.hs.1M.left.fq   # PE reads for heatshock
1M_READS_sample/Sp.hs.1M.right.fq
1M_READS_sample/Sp.log.1M.left.fq  # PE reads for log phase
1M_READS_sample/Sp.log.1M.right.fq
1M_READS_sample/Sp.ds.1M.right.fq   # PE reads for diauxic shock
1M_READS_sample/Sp.ds.1M.left.fq
1M_READS_sample/Sp.plat.1M.left.fq  # PE reads for plateau phase
1M_READS_sample/Sp.plat.1M.right.fq
samples_n_reads_described.txt   # tab-delimited description file.

Please note that this protocol expects the raw data to be of high quality, free from adaptor, barcodes and other contaminating subsequences. De novo RNA-Seq assembly using Trinity Timing: 60–90 min

  1. Create a working folder and place the ‘TrinityNatureProtocolTutorial/’ directory contents there (as per the Materials section).

  2. In order to facilitate downstream analyses, concatenate the RNA-Seq data across all samples into a single set of inputs to generate a single reference Trinity assembly. Combine all ‘left’ reads into a single file, and combine all ‘right’ reads into a single file by:

    % cat 1M_READS_sample/*.left.fq > reads.ALL.left.fq
    % cat 1M_READS_sample/*.right.fq > reads.ALL.right.fq
  3. Assemble the reads into transcripts using Trinity by:

    % $TRINITY_HOME/Trinity.pl --seqType fq --JM 10G \
        --left reads.ALL.left.fq --right reads.ALL.right.fq \
        --SS_lib_type RF --CPU 6

Please note that the --JM option enables the user to control the amount of RAM used during Jellyfish k-mer counting, in this case, 10 Gb. The --CPU option controls the number of parallel processes. Feel free to change these parameters depending on your system. The Trinity reconstructed transcripts will exist as FASTA-formatted sequences in the output file ‘trinity_out_dir/Trinity.fasta’.

  1. Use the script ‘$TRINITY_HOME/utilities/TrinityStats.pl’ to examine the statistic for the Trinity assemblies:

    % $TRINITY_HOME/util/TrinityStats.pl trinity_out_dir/Trinity.fasta

The ‘TrinityStats.pl’ reports the number of transcripts, components, and the transcript contig N50 value based on the ‘Trinity.fasta’ file. The contig N50 value, defined as the maximum length whereby at least 50% of the total assembled sequence resides in contigs of at least that length, is a commonly used metric for evaluating the contiguity of a genome assembly. Note that, unlike genome assemblies, maximizing N50 is not appropriate for transcriptomes; it is more appropriate to use an index based on a reference dataset (from the same or a closely related species) and to estimate the number of reference genes recovered and how many can be deemed to be full-length49, 50 (see below). The N50 value is, however, useful for confirming that the assembly succeeded (you will expect a value that is near the average transcript length of S. pombe , avg. = 1397 bases)

Quality assessment Timing: ~90 min

Note
This section of the Procedure is optional, but we highly recommend its implementation
  1. Examine the breadth of genetic composition and transcript contiguity by leveraging a reference data set. The annotated reference transcriptome of Schizosaccharomyces pombe is included as file ‘S_pombe_refTrans.fasta’. Use megablast and our included analysis script to analyze its representation by the Trinity assembly as described below (Steps 9-13).

  2. Prepare the reference transcriptome fasta file as a BLAST database:

    % makeblastdb -in S_pombe_refTrans.fasta -dbtype nucl
  3. Run megablast to align the known transcripts to the Trinity assembly:

    % blastn -query trinity_out_dir/Trinity.fasta \
        -db S_pombe_refTrans.fasta \
        -out Trinity_vs_S_pombe_refTrans.blastn \
        -evalue 1e-20 -dust no -task megablast -num_threads 2 \
        -max_target_seqs 1 -outfmt 6
  4. Once megablast has completed, run the script below to examine the length coverage of top database hits:

    % $TRINITY_HOME/util/analyze_blastPlus_topHit_coverage.pl  \
              Trinity_vs_S_pombe_genes.blastn \
              trinity_out_dir/Trinity.fasta \
              S_pombe_refTrans.fasta
  5. Examine the number of input RNA-Seq reads that are well represented by the transcriptome assembly. Trinity provides a script ‘alignReads.pl’ that executes Bowtie to align the left and right fragment reads separately to the Trinity contigs and then groups the reads together into pairs while retaining those single read alignments that are not found to be properly paired with their mate. Run ‘alignReads.pl’ by:

    % $TRINITY_HOME/util/alignReads.pl --seqType fq \
                                       --left reads.ALL.left.fq --right reads.ALL.right.fq \
                                       --SS_lib_type RF --retain_intermediate_files \
                                       --aligner bowtie \
                                    --target trinity_out_dir/Trinity.fasta -- -p 4
  6. When ‘alignReads.pl’ is run using strand-specific data, as indicated above with the ‘--SS_lib_type RF’ parameter setting, it will separate the alignments into those that align to the sense strand (‘+’) from the antisense strand (‘-’). All output files including coordinate-sorted and read-name-sorted SAM files should exist in a ‘bowtie_out/’ directory. Count the number of reads aligning (at least once) to the sense strand of transcripts by running the utility below on the sense-strand read name-sorted alignment file as shown:

    % $TRINITY_HOME/util/SAM_nameSorted_to_uniq_count_stats.pl   \
                               bowtie_out/bowtie_out.nameSorted.sam.+.sam

Abundance estimation using RSEM Timing: 40–60 min.

  1. Obtain transcript abundance estimates by running RSEM separately for each sample, as shown below: The PERL script ‘run_RSEM_align_n_estimate.pl’ simply provides an interface to the RSEM software, translating the familiar Trinity command-line parameters to their RSEM equivalents and then executing the RSEM software. Each relevant step below (15–18) generates files ‘$prefix.isoforms.results’ and ‘$prefix.genes.results’, containing the abundance estimations for Trinity transcripts (Table 1) and components (Table 2), respectively. The $prefix in the filename is set based on the ‘--prefix’ setting in the commands below, which is unique to each sample. Please note that, with regard to the parameters reported in Table 1 and Table 2, Transcript_id is the Trinity transcript identifier; Gene_id is the Trinity component to which the reconstructed transcript was derived; Length is the length of the reconstructed transcript; Effective length is the mean number of 5' start positions from which an RNA-Seq fragment could have been derived from this transcript, given the distribution of fragment lengths inferred by RSEM — the value is equal to (transcript_length - mean_fragment_length + 1); Expected count is the number of expected RNA-Seq fragments assigned to the transcript given maximum likelihood transcript abundance estimates; TPM is the number of transcripts per million; FPKM is the number of RNA-Seq fragments per kilobase of transcript effective length per million fragments mapped to all transcripts; and IsoPct is the percent of expression for a given transcript compared to all expression from that Trinity component. Note also that the gene’s length and effective length are defined as the IsoPct weighted sum of transcript lengths and effective lengths. The gene’s expected counts, TPM, and FPKM are defined as the sum of its transcripts' expected counts, TPM and FPKM.

  2. RSEM for log phase

    % $TRINITY_HOME/util/RSEM_util/run_RSEM_align_n_estimate.pl \
       --transcripts trinity_out_dir/Trinity.fasta \
       --left Sp.log.1M.left.fq \
       --right Sp.log.1M.right.fq \
       --seqType fq \
       --SS_lib_type RF \
       --prefix LOG
  3. RSEM for diauxic shift

    % $TRINITY_HOME/util/RSEM_util/run_RSEM_align_n_estimate.pl \
      --transcripts trinity_out_dir/Trinity.fasta \
      --left Sp.ds.1M.left.fq \
      --right Sp.ds.1M.right.fq \
      --seqType fq \
      --SS_lib_type RF \
      --prefix DS
  4. RSEM for heat shock

    % $TRINITY_HOME/util/RSEM_util/run_RSEM_align_n_estimate.pl \
      --transcripts trinity_out_dir/Trinity.fasta \
      --left Sp.hs.1M.left.fq \
      --right Sp.hs.1M.right.fq \
      --seqType fq \
      --SS_lib_type RF \
      --prefix HS
  5. RSEM for plateau phase

    % $TRINITY_HOME/util/RSEM_util/run_RSEM_align_n_estimate.pl \
       --transcripts trinity_out_dir/Trinity.fasta \
       --left Sp.plat.1M.left.fq \
       --right Sp.plat.1M.right.fq \
       --seqType fq \
       --SS_lib_type RF \
       --prefix PLAT

Differential expression analysis using edgeR Timing: <5 min

Note
In this section, the genes and transcripts can be examined separately using their corresponding RSEM abundance estimates. For brevity, we pursue here only the transcripts below.
  1. You will see that each of the RSEM ‘*.isoforms.results’ files has a number of columns, but we only need the one called ‘expected_count’. Create a matrix containing the counts of RNA-seq fragments per feature in a simple tab-delimited text file using the expected fragment count data produced by RSEM.

    % $TRINITY_HOME/util/RSEM_util/merge_RSEM_frag_counts_single_table.pl\
        LOG.isoforms.results DS.isoforms.results HS.isoforms.results \
        PLAT.isoforms.results > Sp_isoforms.counts.matrix

Please note that the first column of the resulting matrix is the name of the transcript. The second, third and so on are the raw counts for each of the corresponding samples. The first row contains the column headings including a label for each sample.

  1. Use edgeR to identify differentially expressed transcripts for each pair of samples. The following script automates many of the tasks of running edgeR or DESeq; in this procedure, we only leverage edgeR. Use the matrix created in Step 19 as input.

    % $TRINITY_HOME/Analysis/DifferentialExpression/run_DE_analysis.pl \
      --matrix Sp_isoforms.counts.matrix \
      --method edgeR \
      --output edgeR_dir

Please note that all the edgeR results from the pairwise comparisons now exist in the ‘edgeR_dir/’ output directory, and also include the following files of interest: *.edgeR.DE_results (differentially expressed transcripts identified, including fold change and statistical significance (Table 3)) and *.edgeR.DE_results.MA_n_Volcano.pdf (MA and volcano plots from pairwise comparisons (Fig. 9)).

  1. To perform TMM normalization and to generate a matrix of expression values measured in FPKM, first extract the transcript length values from any one of RSEM’s *.isoform.results files:

    % cut -f1,3,4 DS.isoforms.results > Trinity.trans_lengths.txt
  2. Now, perform the TMM normalization:

    % $TRINITY_HOME/Analysis/DifferentialExpression/run_TMM_normalization_write_FPKM_matrix.pl \
      --matrix Sp_isoforms.counts.matrix \
      --lengths Trinity.trans_lengths.txt

This command will generate the following files: ‘Sp_isoforms.counts.matrix.TMM_info.txt’, containing the effective library size for each sample after TMM normalization; and ‘Sp_isoforms.counts.matrix.TMM_normalized.FPKM’, which contains normalized transcript expression values according to the transcript and sample, measured as FPKM. This matrix file will be used for clustering expression profiles for transcripts across samples and generating heat map visualizations, as described below.

  1. To study expression patterns of transcripts or genes across samples, it is often useful to restrict analysis to those transcripts that are significantly differentially expressed in at least one pairwise sample comparison. Given a set of differentially expressed transcripts, extract their normalized expression values and perform hierarchical clustering to group together transcripts with similar expression patterns across samples, and to group together those samples that have similar expression profiles according to transcripts. For example, enter the ‘edgeR_dir/’ output directory and extract those transcripts that are at least fourfold differentially expressed with false discovery–corrected statistical significance of at most 0.001 by using the following commands:

    % cd edgeR_dir/
    % $TRINITY_HOME/Analysis/DifferentialExpression/analyze_diff_expr.pl \
      --matrix ./Sp_isoforms.counts.matrix.TMM_normalized.FPKM \
      -C 2 -P 0.001

Please note that the -C parameter takes the log2 (fold_change) cutoff, which in this case is log2(4) = 2. A number of files are generated, all with the prefix ‘diffExpr.P0.001_C2’ indicating the parameter choices: ‘diffExpr.P0.001_C2.matrix’ contains the subset of transcripts from the complete matrix ‘matrix.TMM_normalized.FPKM’ that were identified as differentially expressed, as defined by the specified thresholds. ‘diffExpr.P0.001_C2.matrix.heatmap.pdf’ contains a clustered heat map image showing the relationships among transcripts and samples (Fig. 10a) and a heat map of the pair-wise Spearman correlations between samples (Fig. 10b). ‘diffExpr.P0.001_C2.matrix.R.all.RData’ is a local storage of all the data generated during this analysis, which is used further down in the PROCEDURE (Step 25) with additional analysis tools.

  1. Determine the number of such differentially expressed transcripts by counting the number of lines in the file by using the command:

    % wc -l diffExpr.P0.001_C2.matrix

Subtract 1 so that you do not count the column header line as a transcript entry. Note that the ‘analyze_diff_expr.pl’ script will also directly report the number of differentially expressed transcripts identified at the given thresholds.

  1. Extract clusters of transcripts with common expression profiles from the earlier generated hierarchical clusters by running the script below, which uses R to cut the tree representing the hierarchically clustered transcripts based on specified criteria, such as to generate a specific number of clusters or by cutting the tree at a certain height. For example, run the following to partition transcripts by cutting the tree at 20% of its height:

    % $TRINITY_HOME/Analysis/DifferentialExpression/define_clusters_by_cutting_tree.pl \
      --Ptree 20 -R diffExpr.P0.001_C2.matrix.R.all.Rdata

The above command generates a directory (‘diffExpr.P0.001_C2.matrix.R.all.RData.clusters_fixed_P_20/’) that contains ‘subcluster_*_log2_medianCentered_fpkm.matrix’—each autodefined cluster of transcripts is provided along with expression values that are log2-transformed and median-centered—and ‘my_cluster_plots.pdf’—contains a plot of the log2-transformed, median-centered expression values for each cluster (Fig. 10c). Note that, owing to the wide dynamic range in expression values of transcripts, during this step, the expression values were first log2-transformed before plotting data points. In addition, in order to examine common expression patterns that focus on the relative expression of transcripts across multiple samples, each transcript’s expression value was subsequently centered by the median value. This operation was performed by subtracting each transcript’s median log2(FPKM) value from its log2(FPKM) value in each sample. These resulting data are referred to as log2-transformed, median-centered expression values, as generated in this step.

  1. (Optional) Run the script in Step 25 several times with different values of ‘--Ptree’ in order to increase or decrease the number of clusters generated. Automating the required sections of the PROCEDURE ● TIMING 2–3 h

  2. (Optional) If you are interested in executing the sections of the PROCEDURE without manually typing in each command, run the script below, which executes the required sections of the PROCEDURE. These sections include concatenating all samples’ reads into a single input data set, assembling the reads using Trinity, performing abundance estimation separately for each sample and running edgeR to identify differentially expressed transcripts. Run the automated procedure with the following command, including the -I (optional) parameter for an interactive experience, in which the system will pause and wait for a user response before proceeding to the next step.

    % $TRINITY_HOME/util/run_Trinity_edgeR_pipeline.pl --samples_file samples_n_reads_described.txt -I