function formatDataToArray (data) {
                    var newdata = [];
                    data.forEach(function (item) {
                        // create rows:
                        var row = [];

                        try {
                            var isExpressionAtlas = (otConsts.datasources.EXPRESSION_ATLAS.id === item.evidence.provenance_type.database.id.toLowerCase());

                            // col 0: data origin: public / private
                            row.push((item.access_level === otConsts.ACCESS_LEVEL_PUBLIC) ? otConsts.ACCESS_LEVEL_PUBLIC_DIR : otConsts.ACCESS_LEVEL_PRIVATE_DIR);

                            // disease
                            row.push(item.disease.efo_info.label);

                            // comparison
                            row.push(item.evidence.comparison_name);

                            if (isExpressionAtlas) {
                                var activityUrl = item.evidence.urls.filter(function (i) { return i.nice_name === 'Gene expression in Expression Atlas'; })[0].url || '';
                            } else {
                                var activityUrl = item.evidence.urls[0].url;
                            }
                            var activity = item.target.activity.split('_').shift();
                            row.push('<a class=\'ot-external-link\' href=\'' + activityUrl + '\' target=\'_blank\'>' + activity + '</a>');

                            // tissue / cell
                            row.push(item.disease.biosample.name);

                            // evidence source
                            row.push(otUtils.getEcoLabel(item.evidence.evidence_codes_info, item.evidence.evidence_codes[0]));

                            // fold change
                            row.push(item.evidence.log2_fold_change.value);

                            // p-value
                            row.push((item.evidence.resource_score.value).toExponential(2));

                            // percentile rank
                            row.push(item.evidence.log2_fold_change.percentile_rank);

                            // experiment overview
                            if (isExpressionAtlas) {
                                var expID = (item.evidence.urls.filter(function (i) { return i.nice_name === 'ArrayExpress Experiment overview'; })[0].url || '').split('/').pop();
                                var expOverview = 'https://www.ebi.ac.uk/gxa/experiments/' + expID + '/Experiment%20Design';
                            } else {
                                var expOverview = (item.evidence.urls[2] || item.evidence.urls[0]).url || otDictionary.NA; 
                            }
                            row.push('<a class=\'ot-external-link\' href=\'' + expOverview + '\' target=\'_blank\'>' + (item.evidence.experiment_overview || 'Experiment overview and raw data') + '</a>');


                            // publications
                            var refs = [];
                            if (checkPath(item, 'evidence.provenance_type.literature.references')) {
                                refs = item.evidence.provenance_type.literature.references;
                            }
                            var pmidsList = otUtils.getPmidsList(refs);
                            row.push(otUtils.getPublicationsString(pmidsList));

                            // Publication ids (hidden)
                            row.push(pmidsList.join(', '));

                            // hidden columns for filtering
                            row.push(activity); // activity
                            row.push(item.evidence.experiment_overview || 'Experiment overview and raw data'); // experiment overview + data

                            newdata.push(row); // push, so we don't end up with empty rows
                        } catch (e) {
                            scope.ext.hasError = true;
                            $log.log('Error parsing RNA-expression data:');
                            $log.log(e);
                        }
                    });

                    return newdata;
                }
/*
                 * Takes the data object returned by the API and formats it to an array of arrays
                 * to be displayed by the RNA-expression dataTable widget.
                 */
Takes the data object returned by the API and formats it to an array of arrays
to be displayed by the RNA-expression dataTable widget.
Takes the data object returned by the API and formats it to an array of arrays to be displayed by the RNA - expression dataTable widget .
function formatDataToArray (data) {
                    var newdata = [];
                    data.forEach(function (item) {
                        var row = [];
                        try {
                            var isExpressionAtlas = (otConsts.datasources.EXPRESSION_ATLAS.id === item.evidence.provenance_type.database.id.toLowerCase());
                            row.push((item.access_level === otConsts.ACCESS_LEVEL_PUBLIC) ? otConsts.ACCESS_LEVEL_PUBLIC_DIR : otConsts.ACCESS_LEVEL_PRIVATE_DIR);
                            row.push(item.disease.efo_info.label);
                            row.push(item.evidence.comparison_name);
                            if (isExpressionAtlas) {
                                var activityUrl = item.evidence.urls.filter(function (i) { return i.nice_name === 'Gene expression in Expression Atlas'; })[0].url || '';
                            } else {
                                var activityUrl = item.evidence.urls[0].url;
                            }
                            var activity = item.target.activity.split('_').shift();
                            row.push('<a class=\'ot-external-link\' href=\'' + activityUrl + '\' target=\'_blank\'>' + activity + '</a>');
                            row.push(item.disease.biosample.name);
                            row.push(otUtils.getEcoLabel(item.evidence.evidence_codes_info, item.evidence.evidence_codes[0]));
                            row.push(item.evidence.log2_fold_change.value);
                            row.push((item.evidence.resource_score.value).toExponential(2));
                            row.push(item.evidence.log2_fold_change.percentile_rank);
                            if (isExpressionAtlas) {
                                var expID = (item.evidence.urls.filter(function (i) { return i.nice_name === 'ArrayExpress Experiment overview'; })[0].url || '').split('/').pop();
                                var expOverview = 'https://www.ebi.ac.uk/gxa/experiments/' + expID + '/Experiment%20Design';
                            } else {
                                var expOverview = (item.evidence.urls[2] || item.evidence.urls[0]).url || otDictionary.NA; 
                            }
                            row.push('<a class=\'ot-external-link\' href=\'' + expOverview + '\' target=\'_blank\'>' + (item.evidence.experiment_overview || 'Experiment overview and raw data') + '</a>');
                            var refs = [];
                            if (checkPath(item, 'evidence.provenance_type.literature.references')) {
                                refs = item.evidence.provenance_type.literature.references;
                            }
                            var pmidsList = otUtils.getPmidsList(refs);
                            row.push(otUtils.getPublicationsString(pmidsList));
                            row.push(pmidsList.join(', '));
                            row.push(activity); 
                            row.push(item.evidence.experiment_overview || 'Experiment overview and raw data');  + data
                            newdata.push(row); 
                        } catch (e) {
                            scope.ext.hasError = true;
                            $log.log('Error parsing RNA-expression data:');
                            $log.log(e);
                        }
                    });
                    return newdata;
                }
function formatDataToArray ( data ) { var newdata = [ ] ; data . forEach ( function ( item ) { var row = [ ] ; try { var isExpressionAtlas = ( otConsts . datasources . EXPRESSION_ATLAS . id === item . evidence . provenance_type . database . id . toLowerCase ( ) ) ; row . push ( ( item . access_level === otConsts . ACCESS_LEVEL_PUBLIC ) ? otConsts . ACCESS_LEVEL_PUBLIC_DIR : otConsts . ACCESS_LEVEL_PRIVATE_DIR ) ; row . push ( item . disease . efo_info . label ) ; row . push ( item . evidence . comparison_name ) ; if ( isExpressionAtlas ) { var activityUrl = item . evidence . urls . filter ( function ( i ) { return i . nice_name === 'Gene expression in Expression Atlas' ; } ) [ 0 ] . url || '' ; } else { var activityUrl = item . evidence . urls [ 0 ] . url ; } var activity = item . target . activity . split ( '_' ) . shift ( ) ; row . push ( '<a class=\'ot-external-link\' href=\'' + activityUrl + '\' target=\'_blank\'>' + activity + '</a>' ) ; row . push ( item . disease . biosample . name ) ; row . push ( otUtils . getEcoLabel ( item . evidence . evidence_codes_info , item . evidence . evidence_codes [ 0 ] ) ) ; row . push ( item . evidence . log2_fold_change . value ) ; row . push ( ( item . evidence . resource_score . value ) . toExponential ( 2 ) ) ; row . push ( item . evidence . log2_fold_change . percentile_rank ) ; if ( isExpressionAtlas ) { var expID = ( item . evidence . urls . filter ( function ( i ) { return i . nice_name === 'ArrayExpress Experiment overview' ; } ) [ 0 ] . url || '' ) . split ( '/' ) . pop ( ) ; var expOverview = 'https://www.ebi.ac.uk/gxa/experiments/' + expID + '/Experiment%20Design' ; } else { var expOverview = ( item . evidence . urls [ 2 ] || item . evidence . urls [ 0 ] ) . url || otDictionary . NA ; } row . push ( '<a class=\'ot-external-link\' href=\'' + expOverview + '\' target=\'_blank\'>' + ( item . evidence . experiment_overview || 'Experiment overview and raw data' ) + '</a>' ) ; var refs = [ ] ; if ( checkPath ( item , 'evidence.provenance_type.literature.references' ) ) { refs = item . evidence . provenance_type . literature . references ; } var pmidsList = otUtils . getPmidsList ( refs ) ; row . push ( otUtils . getPublicationsString ( pmidsList ) ) ; row . push ( pmidsList . join ( ', ' ) ) ; row . push ( activity ) ; row . push ( item . evidence . experiment_overview || 'Experiment overview and raw data' ) ; newdata . push ( row ) ; } catch ( e ) { scope . ext . hasError = true ; $log . log ( 'Error parsing RNA-expression data:' ) ; $log . log ( e ) ; } } ) ; return newdata ; }
Takes the data object returned by the API and formats it to an array of arrays
 to be displayed by the RNA-expression dataTable widget.
Takes the data object returned by the API and formats it to an array of arrays to be displayed by the RNA - expression dataTable widget .
// create rows: // col 0: data origin: public / private // disease // comparison // tissue / cell // evidence source // fold change // p-value // percentile rank // experiment overview // publications // Publication ids (hidden) // hidden columns for filtering // activity // experiment overview + data // push, so we don't end up with empty rows