informatics-isi-edu / deriva-webapps

Deriva-based web applications
Apache License 2.0
2 stars 1 forks source link

Add a selector for data for any plot type #172

Closed jrchudy closed 9 months ago

jrchudy commented 11 months ago

This issue is meant to be an incremental change that gets our functionality closer to what is described in issue #156.

For now, only 1 selector will be allowed to be added. This selector will be displayed as a dropdown with the data coming from an ermrest request or hard coded as part of the selector.

Configuration

plots:[{
  plotly: {
    layout: {...},
    config: {...}
  },
  config: {...},
  dropdown: {
    uid*:                   string - key for referencing the dropdown in other configuration properties,
    label*:                 string - name to display next to the dropdown,
    url_param_key?:         string - parameter name from url params that is associated with the dropdown,
    request_info: {
      url_pattern?:            string - string that allows for handlebars templating for fetching data,
      data?:                   array of objects - values to use in the dropdown if no url_pattern is provided, 
      default_value?:          string - the initial value to use on page load (url_param_key can be set to override this),
      value_key*:              string - column to use for templating in queries,
      selected_value_pattern?: string - a pattern string to show in the dropdown for each selected option
      tick_markdown_pattern*:  string - a markdown pattern to be used for the axis labels
    }
  },
  traces: [{...}]
}, ...]

Notes:

Example with "data"

This example is for changing the consortium value that is present in the url_pattern.

plots: [{
  plot_type: 'bar',
  plotly: {...},
  dropdown: {
    uid: 'consortium',
    label: 'Consortium',
    request_info: {
      data: [{
        Name: 'ALL',
        Display: 'All' 
      }, {
        Name: 'GUDMAP',
        Display: 'Gudmap' 
      }, {
        Name: 'RBK',
        Display: 'RBK' 
      }],
      default_value: 'ALL',
      value_key: 'Name',
      selected_value_pattern: '{{{$self.values.Display}}}'
    }
  },
  traces: [{
    url_pattern: '/ermrest/catalog/2/entity/M:=Dashboard:Release_Status/Consortium={{{$control_values.consortium.values.Name}}}/!(%23_Released=0)/!(Data_Type=Antibody)/!(Data_Type::regexp::Study%7CExperiment%7CFile)/$M@sort(ID::desc::)?limit=26',
    x: ['#_Released', '#_Created'],
    y: ['Data_Type'],
    ...
  }]
}, ... ]

Example with "url_pattern"

This example uses the gene selector data to initialize a single dropdown for violin plot assuming we will always use "all studies" and not allow study selection to be changed

plots: [{
  plotly: {...},
  dropdown: {
    uid: 'gene',
    label: 'Filter By',
    url_param_key: 'GeneID',
    request_info: {
      url_pattern: '/ermrest/catalog/2/entity/RNASeq:Replicate_Expression/(NCBI_GeneID)=(Common:Gene:NCBI_GeneID)'.
      default_value: '1',
      value_key: 'NCBI_GeneID',
    }
  },
  traces: [{
    url_pattern: '/ermrest/catalog/2/attributegroup/M:=RNASeq:Replicate_Expression/NCBI_GeneID={{{$control_values.gene.values.NCBI_GeneID}}}/$M/Anatomical_Source,Experiment,Experiment_Internal_ID,NCBI_GeneID,Replicate,Sex,Species,Specimen,Specimen_Type,Stage,Age,Starts_At,Ends_At,TPM',
    ...
  }]
}, ... ]