genomes_genes.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. Genomes and Genes
  2. =================
  3. Loading Feature Data
  4. --------------------
  5. Now that we have our organism and whole genome analysis ready, we can begin loading genomic data. For this tutorial only a single gene from sweet orange will be loaded into the databsae. This is to ensure we can move through the tutorial rather quickly. The following datasets will be used for this tutorial:
  6. - `Citrus sinensis-orange1.1g015632m.g.gff3 <http://tripal.info/sites/default/files/Citrus_sinensis-orange1.1g015632m.g.gff3>`_
  7. - `Citrus sinensis-scaffold00001.fasta <http://tripal.info/sites/default/files/Citrus_sinensis-scaffold00001.fasta>`_
  8. - `Citrus sinensis-orange1.1g015632m.g.fasta <http://tripal.info/sites/default/files/Citrus_sinensis-orange1.1g015632m.g.fasta>`_
  9. One of the new features available in many of the Tripal v3 data loaders is an HTML5 file upload element which allows administrators and users to upload large files reliably. This removes the requirement in previous versions of this tutorial to download these files directly on the server and provide a path to the file. Instead, if you have the file on your current local machine you can now simply upload it for loading.
  10. Another new option in Tripal v3 Data Loaders is the ability to provide a remote path of a file to be loaded. This completely alleviates the need to transfer large files multiple times and eases the loading process.
  11. Loading a GFF3 File
  12. -------------------
  13. The gene features (e.g. gene, mRNA, 5_prime_UTRs, CDS 3_prime_UTRS) are stored in the GFF3 file downloaded in the previous step. We will load this GFF3 file and consequently load our gene features into the database. Navigate to **Tripal → Data Loaders → Chado GFF3 Loader**.
  14. .. image:: genomes_genes.1.png
  15. Enter the following:
  16. .. csv-table::
  17. :header: "Field Name", "Value"
  18. "File", "Upload the file name Citrus_sinensis-orange1.1g015632m.g.gff3"
  19. "Analysis", "Whole Genome Assembly and Annotation of Citrus sinensis"
  20. "Existing Organism", "Citrus sinensis"
  21. "Landmark Type", "supercontig"
  22. "All other options", "leave as default"
  23. .. note::
  24. The Landmark Type is provided for this demo GFF3 file because the chromosome is not defined in the file, only the genomic features on the chromosomes. The landmark type is not needed if the GFF3 file has the chromosomes (scaffolds or contigs) defined in the GFF3 file.
  25. Finally, click the Import GFF3 file button. You'll notice a job was submitted to the jobs subsystem. Now, to complete the process we need the job to run. We'll do this manually:
  26. ::
  27. drush trp-run-jobs --username=administrator --root=/var/www/html
  28. You should see output similar to the following:
  29. ::
  30. 2020-10-02 21:53:18
  31. Tripal Job Launcher
  32. Running as user 'admin'
  33. -------------------
  34. 2020-10-02 21:53:18: There are 1 jobs queued.
  35. 2020-10-02 21:53:18: Job ID 1310.
  36. 2020-10-02 21:53:18: Calling: tripal_run_importer(123)
  37. Running 'Chado GFF3 File Loader' importer
  38. NOTE: Loading of file is performed using a database transaction.
  39. If it fails or is terminated prematurely then all insertions and
  40. updates are rolled back and will not be found in the database
  41. Opening /var/www/html/sites/default/files/tripal/users/1/Citrus_sinensis-orange1.1g015632m.g.gff3
  42. Opening temporary cache file: /tmp/TripalGFF3Import_aUgoru
  43. Step 1 of 26: Caching GFF3 file...
  44. Step 2 of 26: Find existing landmarks...
  45. Step 3 of 26: Insert new landmarks (if needed)...
  46. Step 4 of 26: Find missing proteins...
  47. Step 5 of 26: Add missing proteins to list of features...
  48. Step 6 of 26: Find existing features...
  49. Step 7 of 26: Clear attributes of existing features...
  50. Step 8 of 26: Processing 135 features...
  51. Step 9 of 26: Get new feature IDs...
  52. Step 10 of 26: Insert locations...
  53. Step 11 of 26: Associate parents and children...
  54. Step 12 of 26: Calculate child ranks...
  55. Step 13 of 26: Add child-parent relationships...
  56. Step 14 of 26: Insert properties...
  57. Step 15 of 26: Find synonyms (aliases)...
  58. Step 16 of 26: Insert new synonyms (aliases)...
  59. Step 17 of 26: Insert feature synonyms (aliases)...
  60. Step 18 of 26: Find cross references...
  61. Step 19 of 26: Insert new cross references...
  62. Step 20 of 26: Get new cross references IDs...
  63. Step 21 of 26: Insert feature cross references...
  64. Step 22 of 26: Insert feature ontology terms...
  65. Step 23 of 26: Insert 'derives_from' relationships...
  66. Step 24 of 26: Insert Targets...
  67. Step 25 of 26: Associate features with analysis....
  68. Step 26 of 26: Adding sequences data (Skipped: none available)...
  69. Done.
  70. Committing Transaction...
  71. Remapping Chado Controlled vocabularies to Tripal Terms...
  72. Done.
  73. .. note::
  74. For very large GFF3 files the loader can take quite a while to complete.
  75. Loading FASTA files
  76. -------------------
  77. Using the Tripal GFF3 loader we were able to populate the database with the genomic features for our organism. However, those features now need nucleotide sequence data. To do this, we will load the nucleotide sequences for the mRNA features and the scaffold sequence. Navigate to the **Tripal → Data Loaders → Chado FASTA Loader**.
  78. .. image:: genomes_genes.2.png
  79. Before loading the FASTA file we must first know the Sequence Ontology (SO) term that describes the sequences we are about to upload. We can find the appropriate SO terms from our GFF file. In the GFF file we see the SO terms that correspond to our FASTA files are 'scaffold' and 'mRNA'.
  80. .. note::
  81. It is important to ensure prior to importing, that the FASTA loader will be able to appropriately match the sequence in the FASTA file with existing sequences in the database. Before loading FASTA files, take special care to ensure the definition line of your FASTA file can uniquely identify the feature for the specific organism and sequence type.
  82. For example, in our GFF file an mRNA feature appears as follows:
  83. ::
  84. scaffold00001 phytozome6 mRNA 4058460 4062210 . + . ID=PAC:18136217;Name=orange1.1g015632m;PACid=18136217;Parent=orange1.1g015632m.g
  85. Note that for this mRNA feature the ID is **PAC:18136217** and the name is **orange1.1g015632m**. In Chado, features always have a human readable name which does not need to be unique, and also a unique name which must be unique for the organism and SO type. In the GFF file, the ID becomes the unique name and the Name becomes the human readable name.
  86. In our FASTA file the definition line for this mRNA is:
  87. ::
  88. >orange1.1g015632m PAC:18136217 (mRNA) Citrus sinensis
  89. By default Tripal will match the sequence in a FASTA file with the feature that matches the first word in the definition line. In this case the first word is **orange1.1g015632m**. As defined in the GFF file, the name and unique name are different for this mRNA. However, we can see that the first word in the definition line of the FASTA file is the name and the second is the unique name. Therefore, when we load the FASTA file we should specify that we are matching by the name because it appears first in the definition line.
  90. If however, we cannot guarantee the that feature name is unique then we can use a regular expressions in the **Advanced Options** to tell Tripal where to find the name or unique name in the definition line of your FASTA file.
  91. .. note::
  92. When loading FASTA files for features that have already been loaded via a GFF file, always choose "Update only" as the import method. Otherwise, Tripal may add the features in the FASTA file as new features if it cannot properly match them to existing features.
  93. Now, enter the following values in the fields on the web form:
  94. .. csv-table::
  95. :header: "Field Name", "Value"
  96. "FASTA file", "Upload the file named Citrus_sinensis-scaffold00001.fasta"
  97. "Analysis", "Whole Genome Assembly and Annotation of Citrus sinensis"
  98. "Organism", "Citrus sinensis (Sweet orange)"
  99. "Sequence type", "supercontig (scaffold is an alias for supercontig in the sequence ontology)"
  100. "Method", "Update only (we do not want to insert these are they should already be there)"
  101. "Name Match Type", "Name"
  102. Click the Import Fasta File, and a job will be added to the jobs system. Run the job:
  103. ::
  104. drush trp-run-jobs --username=administrator --root=/var/www/html
  105. Notice that the loader reports the it "Found 1 sequences(s).". Next fill out the same form for the mRNA (transcripts) FASTA file:
  106. .. csv-table::
  107. :header: "Field Name", "Value"
  108. "FASTA file", "Upload the file named Citrus_sinensis-orange1.1g015632m.g.fasta"
  109. "Analysis", "Whole Genome Assembly and Annotation of Citrus sinensis"
  110. "Organism", "Citrus sinensis (Sweet orange)"
  111. "Sequence type", "mRNA"
  112. "Method", "Update only"
  113. "Name Match", "Name"
  114. The FASTA loader has some advanced options. The advanced options allow you to create relationships between features and associate them with external databases. For example, the definition line for the mRNA in our FASTA file is:
  115. ::
  116. >orange1.1g015632m PAC:18136217 (mRNA) Citrus sinensis
  117. Here we have more information than just the feature name. We have a unique Phytozome accession number (e.g. PAC:18136217) for the mRNA. Using the **External Database Reference** section under **Additional Options** we can import this information to associate the Phytozome accession with the features. A regular expression is required to uniquely capture that ID. In the example above the unique accession is 18136217. Because Tripal is a PHP application, the syntax for regular expressions follows the PHP method. Documentation for regular expressions used in PHP can be found `here <http://php.net/manual/en/reference.pcre.pattern.syntax.php>`_. Enter the following value to make the associate between the mRNA and it's corresponding accession at Phytozome:
  118. .. csv-table::
  119. :header: "Field Name", "Value"
  120. "External Database", "Phytozome"
  121. "Regular expression for the accession", "^.*PAC:(\d+).*$"
  122. Remember, we have the name **Phytozome** in our **External Database** drop down because we manually added it as a database cross reference earlier in the turorial. After adding the values above, click the **Import FASTA file** button, and manually run the submitted job:
  123. ::
  124. drush trp-run-jobs --username=administrator --root=/var/www/html
  125. Now the scaffold sequence and mRNA sequences are loaded!
  126. .. note:
  127. If the name of the gene to which this mRNA belonged was also on the definition line, we could use the **Relationships** section in the **Advanced Options** to link this mRNA with it's gene parent. Fortunately, this information is also in our GFF file and these relationships have already been made.
  128. .. note::
  129. It is not required to load the mRNA sequences as those can be derived from their alignments with the scaffold sequence. However, in Chado the **feature** table has a **residues** column. Therefore, it is best practice to load the sequence when possible.
  130. Creating Gene Pages
  131. -------------------
  132. Now that we've loaded our feature data, we must publish them. This is different than when we manually created our Organism and Analysis pages. Using the GFF and FASTA loaders we imported our data into Chado, but currently there are no published pages for this data that we loaded. To publish these genomic features, navigating to Structure → Tripal Content Types and click the link titled Publish Chado Content. The following page appears:
  133. .. image:: genomes_genes.3.png
  134. Here we can specify the types of content to publish. For our site we want to offer both gene and mRNA pages (these types were present in our GFF file). First, to create pages for genes select 'Gene' from the dropdown. A new Filter section is present and when opened appears as follows.
  135. .. image:: genomes_genes.4.png
  136. The **Filters** section allows you to provide filters to limit what you want to publish. For example, if you only want to publish genes for a single organism you can select that organism in the Organism drop down list. We only have one organism in our site, but for the sake of experience, add a filter to publish only genes for Citrus sinesis by selecting it from the Organism drop down. Scroll to the bottom a click the Publish button. A new job is added to the job queue. Manually run the job:
  137. ::
  138. drush trp-run-jobs --username=administrator --root=/var/www/html
  139. You should see output similar to the following:
  140. ::
  141. Tripal Job Launcher
  142. Running as user 'administrator'
  143. -------------------
  144. Calling: tripal_chado_publish_records(Array, 12)
  145. NOTE: publishing records is performed using a database transaction.
  146. If the load fails or is terminated prematurely then the entire set of
  147. is rolled back with no changes to the database
  148. Succesfully published 1 Gene record(s).
  149. Here we see that 1 gene was successfully published. This is because the GFF file we used previously to import the genes only had one gene present.
  150. Now, repeat the steps above to publish the mRNA content type. You should see that 9 mRNA records were published:
  151. ::
  152. Tripal Job Launcher
  153. Running as user 'administrator'
  154. -------------------
  155. Calling: tripal_chado_publish_records(Array, 13)
  156. NOTE: publishing records is performed using a database transaction.
  157. If the load fails or is terminated prematurely then the entire set of
  158. is rolled back with no changes to the database
  159. Succesfully published 9 mRNA record(s).
  160. .. note::
  161. It is not necessary to publish all types of features in the GFF file. For example, we do not want to publish features of type **scaffold**. The feature is large and would have many relationships to other features, as well as a very long nucleotide sequence. These can greatly slow down page loading, and in general would be overwhelming to the user to view on one page. As another example, each **mRNA** is composed of several **CDS** features. These **CDS** features do not need their own page and therefore do not need to be published.
  162. Now, we can view our gene and mRNA pages. Click the Find Tripal Content link. Find and click the new page titled **orange1.1g015632m.g**. Here we can see the gene feature we added and its corresponding mRNA's.
  163. .. image:: genomes_genes.5.png
  164. Next find an mRNA page to view. Remember when we loaded our FASTA file for mRNA that we associated the record with Phytozome. On these mRNA pages you will see a link in the left side bar titled **Database Cross Reference**. Clicking that will open a panel with a link to Phytozome. This link appears because:
  165. - We added a Database Cross Reference for Phytozome in a previous step
  166. - We associated the Phytozome accession with the features using a regular expression when importing the FASTA file.
  167. All data that appears on the page is derived from the GFF file and the FASTA files we loaded.
  168. Customizing Transcripts on Gene Pages
  169. -------------------------------------
  170. By default the gene pages provided by Tripal will have a link in the sidebar table of contents named **Transcripts** and when clicked a table appears that lists all of the transcripts (or mRNA) that belong to the gene. The user can click to view more information about each published transcript.
  171. .. image:: genomes_genes.6.png
  172. Sometimes however, more than just a listing of transcripts is desired on a gene page. You can customize the information that is presented about each transcript by navigating to the gene content type at **Structure → Tripal Content Types** and clicking **mange fields** in the **Gene** row. This page allows you to customize the way fields are displayed on the gene page. Scroll down the page to the **Transcript** row and click the **edit** button. The following page should appear.
  173. .. image:: genomes_genes.7.png
  174. Open the field set titled **Transcript (mRNA) Field Selection** to view a table that lists all of the available fields for a transcript.
  175. .. image:: genomes_genes.8.png
  176. On this page you can check the boxes next to the field that you want to show for a transcript on the gene page. For this example, we will select the fields **Name**, **Identifier**, **Resource Type**, **Anotations**, and **Sequences** (they may not be in this order on your own site). You can control the order in which fields will be shown by dragging them using the crosshairs icon next to each one. Scroll to the bottom of the page and click the **Save Settings** button.
  177. Next return to the gene page, reload it, and click on the **Transcripts** link. Now you are provided a select box with the transcript names. When a transcript is selected, the pane below will populate with the fields that you selected when editing in the Transcript field.
  178. .. image:: genomes_genes.9.png
  179. You can return to the Transcript field edit page under the Gene content type at any time to add, remove or change the order of fields that appear for the transcript.
  180. .. note::
  181. Transcripts on a gene page can only be customized if all of them are published. If not, the default table listing is shown.