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

Not working for {gt} tables #66

Open
moldach opened this issue May 17, 2021 · 1 comment
Open

Not working for {gt} tables #66

moldach opened this issue May 17, 2021 · 1 comment

Comments

@moldach
Copy link

moldach commented May 17, 2021

{manipulateWidget} is not working for RStudio's {gt} package:

Given the following two files as input for {gt} and {DiagrammeR} we will try and use the package to display both widgets next to each other:

Input files

A text file result.txt:

entity	information
"**_statTest** ; The statistical test performed to interpret the results of the study. _e.g._ **Linear Regression**, **Logistic Regression**, **Gene Burden Test (SKAT)**, **Gene Burden Test (cmcWald)**, **Survival (SKAT)**, **Survival (Burden)**"	Logisitc Regression
"**_metaAnalysisTestType** ; The type of meta-analysis run. Values must be one of: **Cochran's Q Test**, **Fixed Effects**, **Random Effects**, **Fixed Effects and Random Effects**", **Unknown**, and **NA**
**_sampleSizeTotal** ; The sample size (N) of total observations	216257
**_numGenotypesPerMarker** ; The number of genotypes per marker used for the statistical test of association. This may be different from the sample size of the subjects since some genotypes may fail QC	_NA_
**_pValue_** ; A quantitative confidence value that represents the probability of obtaining a result at least as extreme as that actually obtained  assuming that the actual value was the result of chance alone. This version will transform any values <=5e-324 to 5e-324 (the lower limit of double values)	0.04726
"**_pValueOrig** ; The [pValueOrig](http://purl.obolibrary.org/obo/OBI_0000175) quantitative confidence value that represents the probability of obtaining a result at least as extreme as that actually obtained, assuming that the actual value was the result of chance alone. This version will contain the raw values provided in string format to avoid any float conversion errors"	0.04726
**_standardError** ; The [standard error](https://en.wikipedia.org/wiki/Standard_error) of a statistic is the standard deviation of its sampling distribution	0.0607
**_zScore** ; A [z-score](https://en.wikipedia.org/wiki/Standard_score) is the signed number of standard deviations by which the value of an observation or data point differs from the mean value of what is being observed or measured	NA
**_oddsRatio** ; [oddsRatio](https://en.wikipedia.org/wiki/Odds_ratio) is the quantification of how strongly the presence or absence of property A is associated with the presence or absence of property B in a given population	0.8865657
**_beta** ; The [beta coefficient](https://www.listendata.com/2015/04/standardized-vs-unstandardized.html). It represents the amount by which dependent variable changes if we change independent variable by one unit keeping other independent variables constant	-0.1204
"**_bayesFactor** ; The [Bayes factor](https://en.wikipedia.org/wiki/Bayes_factor) is a ratio of the likelihood probability of two competing hypotheses, usually a null and an alternative"	_NA_
**_fdr** ; The False Discovery Rate (FDR) of a set of predictions is the expected percent of false predictions in the set of predictions	_NA_
**_ciLower** ; The lower bound of a [confidence interval](https://en.wikipedia.org/wiki/Confidence_interval)	_NA_
**_ciUpper** ; The upper bound of a [confidence interval](https://en.wikipedia.org/wiki/Confidence_interval)	_NA_
"**_ciPercentile** ; The percentile used for determining a confidence interval. If this field is filled in, then ciUper and ciLower must be filled in"	_NA_
**_numBurdenMarkers** ; The number of markers examined for the statistical test performed in a gene burden test	_NA_
**_isPrimaryAnalysisPValue** ; A boolean value that indicates if the values in this entity (_i.e._ `pValue`) should be used as the main results when examining a gene in a dataset for GERMLINE scoring algorithms	TRUE
**_copyNumber** ; The number of measured copies found for a specific Copy Number Variation (CNV) marker	_NA_
"**_hazardRatio** ; In survival analysis, the [hazard ratio](https://en.wikipedia.org/wiki/Hazard_ratio) (HR) is the ratio of the hazard rates corresponding to the conditions described by two levels of an explanatory variable"	_NA_
**_effectDirection** ; The direction of effect that a marker or allele has on a trait. Two possible values (**+** or **-**). In the context of a _case/control_ analysis **+** implies increased risk  **-** implies decreased risk ; in the context of a _quantitative trait_  **+** means increased value **-** means decreased value	**-**
**cochranQStat** ; The test statistic for a Cochran's Q Test for heterogeneity of effect sizes. [Cochran's Q test](https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/cochran.htm) is a non-parametric statistical test to verify whether k treatments have identical effects	_NA_

And a edr.gv file like:

digraph Association{
   node [shape=box, style=rounded]
   Lorem -> ipsum
   dolor -> sit
   sit -> amet
   amet -> Lorem
   amet -> consectetur
   amet -> adipiscing
   amet -> elit
   Lorem -> sed [optional="true"]
   sed -> Lorem [optional="true"]
   Lorem -> do
   do -> eiusmod [optional="true"]
   do -> tempor [optional="true"]
   do -> incididunt [optional="true"]
   ut -> do [optional="true"]
   do -> labore [optional="true"]
   git -> labore [optional="true"]
   do -> et
   et -> do
   ipsum -> et
   dolore -> ipsum [optional="true"]
   magna -> ipsum [optional="true"]
   ipsum -> aliqua [optional="true"]
   ipsum -> enim [optional="true"]
}

Plotting

We will try and place a {gt} table next to the diagram

Create a plot {gt} regularly

library(vroom)
library(gt)

# load table
entity_table <- vroom::vroom("result.txt", delim = "\t")

# create table and diagram
table <- entity_table %>% 
  mutate(entity = str_replace_all(entity, ";", "<br>")) %>% 
  gt() %>% 
  fmt_markdown(columns =  everything()) %>% 
  tab_header(
    title = md("**Lorem**"),
    subtitle = md("Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content.")
  ) %>% 
  tab_options(
    column_labels.hidden = TRUE,
    table.font.size = px(12L)
  ) %>% 
    fmt_missing(
    columns = 1:2,
    missing_text = "---"
  )
  
table

Rplot

Create a EDR diagram

library(DiagrammeR)
diagram <- DiagrammeR::grViz('edr.gv')

Demonstrate bug

library(manipulateWidget)
combineWidgets(ncol=2, table, diagram)

broken

Works for two {DiagrammeR} widgets though

library(manipulateWidget)
combineWidgets(ncol=2, diagram, diagram)

works

@bthieurmel
Copy link
Collaborator

Hi, gt is not a htmlwidgets tools, so not working with manipulateWidget

https://cran.r-project.org/web/packages/htmlwidgets/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants