Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a selector for data for any plot type #172

Closed
jrchudy opened this issue Aug 2, 2023 · 0 comments · Fixed by #177
Closed

Add a selector for data for any plot type #172

jrchudy opened this issue Aug 2, 2023 · 0 comments · Fixed by #177
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed plot

Comments

@jrchudy
Copy link
Member

jrchudy commented Aug 2, 2023

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:

  • url_param_key can be defined to allow for a url parameter to be used to initialize the dropdown and fetch data using the url param value
  • 1 of url_pattern or data has to be defined for this dropdown to have data in it
    • show configuration warning alert and show the dropdown as empty
    • still try to fetch data as if no option was selected and let the rest of the code handle any errors that occur
    • this property is used to fetch the value from the url and store it in $control_values.<dropdown.uid>.values.<dropdown.value_key>
  • default_value should be set if fetching data for the plot relies on a value being selected
    • needs to be a valid value for value_key in each row that is returned from url_pattern or data
  • selected_value_pattern is optional. If not defined, use rowname (if url_pattern) or the value_key
  • This property will be accessed in templating user the $control_values namespace
    • this replaces $url_parameters that was introduced with violin plot
    • support both, mark url_parameters as deprecated
    • the selected data will be made available in templating
      • $control_values.<dropdown.uid>.values.<dropdown.value_key>

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',
    ...
  }]
}, ... ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed plot
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants