Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Perrett committed Aug 19, 2022
2 parents abd7b5b + b2888ee commit dd0282d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genoverse",
"version": "4.0.7",
"version": "4.0.8",
"description": "Genoverse is a portable, customizable, back-end independent JavaScript and HTML5 based genome browser which allows the user to explore data in a dynamic and interactive manner.",
"main": "src/js/Genoverse.js",
"directories": {
Expand Down
56 changes: 37 additions & 19 deletions src/js/Track/View/Gene/Ensembl.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,64 @@
import View from '../Gene';

/**
* Provides a function setFeatureColor for defining the feature colour and legend label
* for ensembl genes and transcripts based on their logic_name and biotype properties.
*
* Biotypes are defined in
* https://www.ensembl.org/info/genome/genebuild/biotypes.html
*
* Ensembl colours are defined in
* https://github.com/Ensembl/ensembl-webcode/blob/main/conf/ini-files/COLOUR.ini
*/

export default View.extend({
setFeatureColor: function (feature) {
const processedTranscript = {
'sense_intronic' : 1,
'sense_overlapping' : 1,
'processed_transcript' : 1,
'nonsense_mediated_decay' : 1,
'non_stop_decay' : 1,
'antisense' : 1,
'retained_intron' : 1,
'tec' : 1,
'non_coding' : 1,
'ambiguous_orf' : 1,
'disrupted_domain' : 1,
'3prime_overlapping_ncrna' : 1,
'sense_intronic' : 1,
'sense_overlapping' : 1,
'processed_transcript' : 1,
'nonsense_mediated_decay' : 1,
'non_stop_decay' : 1,
'antisense' : 1,
'retained_intron' : 1,
'tec' : 1,
'non_coding' : 1,
'ambiguous_orf' : 1,
'disrupted_domain' : 1,
'3prime_overlapping_ncrna' : 1,
'protein_coding_CDS_not_defined' : 1, // new in e108
};

feature.color = '#000000';

if (feature.logic_name.indexOf('ensembl_havana') === 0) {
const logicName = feature.logic_name || '';
const biotype = (feature.biotype || '').toLowerCase();

if (logicName.indexOf('ensembl_havana') === 0) {
feature.color = '#CD9B1D';
feature.labelColor = '#B78000';
feature.legend = 'Merged Ensembl/Havana';
} else if (processedTranscript[feature.biotype.toLowerCase()]) {
} else if (processedTranscript[biotype]) {
feature.color = '#0000FF';
feature.legend = 'Processed transcript';
} else if (feature.biotype === 'protein_coding') {
} else if (feature.biotype.indexOf('protein_coding') > -1) {
feature.color = '#A00000';
feature.legend = 'Protein coding';
} else if (feature.biotype.indexOf('pseudogene') > -1) {
} else if (feature.biotype === 'artifact' || biotype.indexOf('pseudogene') > -1) {
feature.color = '#666666';
feature.legend = 'Pseudogene';
} else if (/rna/i.test(feature.biotype) || feature.biotype === 'ribozyme') {
} else if (/rna/.test(biotype) || biotype === 'ribozyme') {
feature.color = '#8B668B';
feature.legend = 'RNA gene';
} else if (/^tr_.+_gene$/i.test(feature.biotype)) {
} else if (/^tr(?:_.+)?_gene$/.test(biotype)) {
feature.color = '#CD6600';
feature.legend = 'TR gene';
} else if (/^ig_.+_gene$/i.test(feature.biotype)) {
} else if (/^ig_.+_gene$/.test(biotype)) {
feature.color = '#8B4500';
feature.legend = 'IG gene';
} else if (biotype === 'lrg_gene') {
feature.color = '#8080FF';
feature.legend = 'LRG gene';
}

feature.labelColor = feature.labelColor || feature.color;
Expand Down
28 changes: 28 additions & 0 deletions test/View/calculate-biotype-legend.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { $, Genoverse, afterTest } = require('../utils');

describe('All ensembl biotypes should be categorised by setFeatureColor:', () => {
afterEach(afterTest);

// select * from (select distinct(biotype) from transcript union select distinct(biotype) from gene) biotypes order by biotype;
const ensemblBiotypes = [ 'artifact', 'IG_C_gene', 'IG_C_pseudogene', 'IG_D_gene', 'IG_J_gene', 'IG_J_pseudogene', 'IG_pseudogene', 'IG_V_gene', 'IG_V_pseudogene', 'lncRNA', 'LRG_gene', 'miRNA', 'misc_RNA', 'Mt_rRNA', 'Mt_tRNA', 'nonsense_mediated_decay', 'non_stop_decay', 'processed_pseudogene', 'processed_transcript', 'protein_coding', 'protein_coding_LoF', 'pseudogene', 'retained_intron', 'ribozyme', 'rRNA', 'rRNA_pseudogene', 'scaRNA', 'scRNA', 'snoRNA', 'snRNA', 'sRNA', 'TEC', 'transcribed_processed_pseudogene', 'transcribed_unitary_pseudogene', 'transcribed_unprocessed_pseudogene', 'translated_processed_pseudogene', 'translated_unprocessed_pseudogene', 'TR_C_gene', 'TR_D_gene', 'TR_J_gene', 'TR_J_pseudogene', 'TR_V_gene', 'TR_V_pseudogene', 'unitary_pseudogene', 'unprocessed_pseudogene', 'vault_RNA' ];

ensemblBiotypes.forEach(
biotype => it(
`${biotype} should be categorised by setFeatureColor`, () => {
const feature = { logic_name: '', biotype: biotype };

const [ track ] = new Genoverse({
chr : 1,
start : 1,
end : 100,
chromosomeSize : 100,
tracks : [ Genoverse.Track.Gene.extend($.extend(true, {}, { data: [ feature ] })) ],
}).tracks;

track.view.setFeatureColor(feature);

expect(feature.legend).toBeDefined();
}
)
);
});

0 comments on commit dd0282d

Please sign in to comment.