Git Product home page Git Product logo

medplot's Introduction

medplot R package

Functions for visualizing and analyzing medical data in R - primarily longitudinal epidemiologic data.

You can find the Excel template file (to use with the medplot shiny app) in the folder:

/inst/extdata/PlotSymptoms_shiny.xlsx

And the Tab Separated Values template file in the folder:

/inst/extdata/PlotSymptoms_TemplateTSV.txt

Docker installation

Medplot package is contained in a docker image located at: https://hub.docker.com/r/crtahlin/medplot/

Make sure you have docker installed. Instructions for various platforms can be found on: https://docs.docker.com/engine/installation/

Run the docker container (it is automatically downloaded) by running the following in a shell:

sudo docker run -d -p 3838:3838 crtahlin/medplot

Open your browser and connect to: http://localhost:3838/shinyapp_symptoms2/

Medplot app should open in your browser.

General installation instructions for the medplot package

After installing the R programming language, use the console in R to install the devtools package:

install.packages("devtools")

Make sure you install the development tools mentioned on the devtools web page. For MS Windows, this would be the Rtools package.

Perl has to be installed in order to enable importing of MS Excel files. For MS Windows, Strawberry perl should work. Reboot computer.

Load devtools and install packages from GitHub:

library(devtools)
install_github("crtahlin/medplot")

Running medplot localy

To run medplot:

library(medplot)
medplotOnline()

This should open the application in a web browser.

Troubleshooting Linux installation

Some specific problems arose while installing on Linux (Ubuntu 14.04). Solutions are listed below.

Prerequisite for the devtools package - use terminal to:

 sudo apt-get install libcurl4-openssl-dev

Prerequisite for the Cairo & medplot packages - use terminal to:

 sudo apt-get install libcairo2-dev
 sudo apt-get install libxt-dev     

as described in http://stackoverflow.com/questions/16678934/r-cairo-installation-without-apt-get-sudo

Prerequisite for the XML & medplot package - use terminal to:

 sudo apt-get install r-cran-xml

as described in http://stackoverflow.com/questions/7765429/unable-to-install-r-package-in-ubuntu-11-04

medplot's People

Contributors

crtahlin avatar llaarraa avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

medplot's Issues

Rename OUTPUT$ vars

Rename all UI vars as in example:
cluteringUI -> UIclustering

As other output are also in this format (plotXYZ,) and it is easier to read.

Clustering - error management at symptoms selection

Add appropriate errors for:

  • at least two symptoms have to be selected to cluster?
  • check the other errors and do the in a user friendly manner

E.g.: "Please select at least two symptoms to generate ...."

Se warning, error and message functions. Also try and tryCatch.

Proportions - change the height of the figure

Change the height of the figure dynamically, depending on the number of symptoms selected. This requires changes in the renderPlot function(how large is the image) as well as the plotOutput function(how much HTML space it gets).

Add to Graph1 - faceting for groups

Add/allow for extra columns in the Excel file with data. The user can choose which one of the columns (all possible as candidates in first implementation) will be used for faceting. The option of using none for faceting is also valid.

Cosmetic issues

Remove the message
WORKING WITH DEMO DATA!
appearing in the first tab before demo data are loaded

Create graph 3 on separate tab

Create a clustering visualization of the data.

The code for tha graphs exist, but has to be modified for the particular application.

@llaarraa : please copy-paste the relevant code in this thread and reassign it back to me.

Graph Timeline

The upper part of the graph is cut off (intensity of the symtoms appears only for large values - problem that appears when selecting all the symptoms, too many, the legend is alligned with the lower margin of the graph; the upper part is cut off )

Proportions - add tables with statistics

Several tables should be added:
Table "1"
Rows: all the symptoms selected
Columns:

  • Proportion of positive in Group1 (0.00)
  • Positive / All in Group1 (102/300)
  • Proportion of positive in Group2 (0.00)
  • Positive / All in Group2 (102/300)
  • P-value (of differences in proportions test) (0.00)
  • Confidence interval (of differences in proportions test) (0.00 ; 0.00)
    Threshold value should be used to establish which symptoms are positive. A table should be generated for each of the measurement occasions.

Table "2"
Rows: all the symptoms selected
Columns:

  • Median of G1
  • IQR of G1
  • Median of G2
  • IQR of G2
  • P-value (returned by Mann-Whitney non parametric test of median equality, found as wilcox.test() in R)
    The symptoms threshold value used is always 0.

Table "3", "4"
Versions of above tables, but without the groups (and obviously without the P-values and confidence limits).

Create graph 4 on separate tab

Create graphs of logistic regresion depending (odds ratio) for different groups in the data.

Code for graphs exists.

@llaarraa : Please copy relevant code into thread and reassign back to me.

Threshold values should infuence dataFiltered.yn

Make sure the threshold value set by user influences the dataFiltered.yn() fnuction, which passes symptoms present to other functions.

Check if everything works correctly after change (if any is needed).

functions not found

With the current installations the functions saved in separate files are not found
could not find function "plotPropWithSymptoms"
could not find function "tablePropWithSymptoms"
could not find function "tableMediansWithSymptoms"
could not find function "tableAllWithSymptoms"

Make plotting death a parameter

Add to Excel options for user to:

  • choose plotting of "death" (or potentialy some other date) YES/NO
  • choose from which column should the date be selected

This could also be just one option, depending on design.

before selecting symptoms: error appearing

Before symptoms are selected in the graph tab an error notice appears: Error: object 'value' not found - fix so that instead of error a warning saying "Select one or more variables to analyze in the left sidebar"

lubridate package

Error in library(lubridate) : there is no package called ‘lubridate’

install.packages("SVGAnnotation", repos="http://www.omegahat.org/R", type="source")
Warning in install.packages :
package ‘SVGAnnotation’ is not available (for R version 3.0.1)
Installing package into ‘C:/Users/lara/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://www.omegahat.org/R/src/contrib/SVGAnnotation_0.93-1.tar.gz'
Content type 'application/x-gzip' length 4625544 bytes (4.4 Mb)
opened URL
downloaded 4.4 Mb

  • installing source package 'SVGAnnotation' ...
    ** R
    ** data
    ** inst
    ** preparing package for lazy loading
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'XML' was built under R version 3.0.2
    in method for 'genEdgeIds' with signature '"Ragraph"': no definition for class "Ragraph"
    in method for 'genEdgeIds' with signature '"graphNEL"': no definition for class "graphNEL"
    Creating a generic function from function 'getEdgeInfo' in package 'SVGAnnotation'
    in method for 'getEdgeInfo' with signature '"graphNEL"': no definition for class "graphNEL"
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
    *** arch - i386
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'XML' was built under R version 3.0.2
    *** arch - x64
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'XML' was built under R version 3.0.2
  • DONE (SVGAnnotation)

The downloaded source packages are in
‘C:\Users\lara\AppData\Local\Temp\Rtmpg1AEwq\downloaded_packages’

library(devtools)
Warning message:
package ‘devtools’ was built under R version 3.0.2
install_github(username="crtahlin", repo="medplot", ref="crt")
Installing github repo medplot/crt from crtahlin
Downloading medplot.zip from https://github.com/crtahlin/medplot/archive/crt.zip
Error: server error: (500) Internal Server Error

install.packages("SVGAnnotation", repos="http://www.omegahat.org/R", type="source")
Warning in install.packages :
package ‘SVGAnnotation’ is not available (for R version 3.0.1)
Installing package into ‘C:/Users/lara/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://www.omegahat.org/R/src/contrib/SVGAnnotation_0.93-1.tar.gz'
Content type 'application/x-gzip' length 4625544 bytes (4.4 Mb)
opened URL
downloaded 4.4 Mb

  • installing source package 'SVGAnnotation' ...
    ** R
    ** data
    ** inst
    ** preparing package for lazy loading
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'XML' was built under R version 3.0.2
    in method for 'genEdgeIds' with signature '"Ragraph"': no definition for class "Ragraph"
    in method for 'genEdgeIds' with signature '"graphNEL"': no definition for class "graphNEL"
    Creating a generic function from function 'getEdgeInfo' in package 'SVGAnnotation'
    in method for 'getEdgeInfo' with signature '"graphNEL"': no definition for class "graphNEL"
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
    *** arch - i386
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'XML' was built under R version 3.0.2
    *** arch - x64
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'XML' was built under R version 3.0.2
  • DONE (SVGAnnotation)

The downloaded source packages are in
‘C:\Users\lara\AppData\Local\Temp\Rtmpg1AEwq\downloaded_packages’

library(devtools)
install_github(username="crtahlin", repo="medplot", ref="Crt")
Installing github repo medplot/Crt from crtahlin
Downloading medplot.zip from https://github.com/crtahlin/medplot/archive/Crt.zip
Installing package from C:\Users\lara\AppData\Local\Temp\Rtmpg1AEwq/medplot.zip
Installing medplot
"C:/PROGRA1/R/R-301.1/bin/x64/R" --vanilla CMD INSTALL
"C:\Users\lara\AppData\Local\Temp\Rtmpg1AEwq\devtools29b4401c1c92\medplot-Crt"
--library="C:/Users/lara/Documents/R/win-library/3.0" --install-tests

  • installing source package 'medplot' ...
    ** R
    ** inst
    ** preparing package for lazy loading
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'gplots' was built under R version 3.0.2
    Warning: package 'shiny' was built under R version 3.0.3
    Warning: package 'scales' was built under R version 3.0.3
    Warning: package 'ggplot2' was built under R version 3.0.3
    Warning: package 'seriation' was built under R version 3.0.3
    Warning: package 'XML' was built under R version 3.0.2
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
    *** arch - i386
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'gplots' was built under R version 3.0.2
    Warning: package 'shiny' was built under R version 3.0.3
    Warning: package 'scales' was built under R version 3.0.3
    Warning: package 'ggplot2' was built under R version 3.0.3
    Warning: package 'seriation' was built under R version 3.0.3
    Warning: package 'XML' was built under R version 3.0.2
    *** arch - x64
    Warning: package 'Cairo' was built under R version 3.0.2
    Warning: package 'gplots' was built under R version 3.0.2
    Warning: package 'shiny' was built under R version 3.0.3
    Warning: package 'scales' was built under R version 3.0.3
    Warning: package 'ggplot2' was built under R version 3.0.3
    Warning: package 'seriation' was built under R version 3.0.3
    Warning: package 'XML' was built under R version 3.0.2
  • DONE (medplot)

    runApp(file.path(path.package("medplot"), "shinyapp_symptoms2" ))
    Error: could not find function "runApp"

    library(shiny)
    Warning message:
    package ‘shiny’ was built under R version 3.0.3

    runApp(file.path(path.package("medplot"), "shinyapp_symptoms2" ))
    Error in path.package("medplot") : none of the packages are loaded

    library(medplot)
    Loading required package: Cairo
    Loading required package: gplots
    KernSmooth 2.23 loaded
    Copyright M. P. Wand 1997-2009

Attaching package: ‘gplots’

The following object is masked from ‘package:stats’:

lowess

Loading required package: RColorBrewer
Loading required package: scales
Loading required package: reshape2
Loading required package: ggplot2
Need help? Try the ggplot2 mailing list: http://groups.google.com/group/ggplot2.
Loading required package: seriation
Loading required package: XML
Loading required package: plyr

Attaching package: ‘medplot’

The following object is masked from ‘package:gplots’:

plotCI

Warning messages:
1: package ‘Cairo’ was built under R version 3.0.2
2: package ‘gplots’ was built under R version 3.0.2
3: package ‘scales’ was built under R version 3.0.3
4: package ‘ggplot2’ was built under R version 3.0.3
5: package ‘seriation’ was built under R version 3.0.3
6: package ‘XML’ was built under R version 3.0.2

runApp(file.path(path.package("medplot"), "shinyapp_symptoms2" ))
Warning: package ‘gdata’ was built under R version 3.0.2
gdata: Unable to locate valid perl interpreter
gdata:
gdata: read.xls() will be unable to read Excel XLS and XLSX files unless the 'perl=' argument is used to specify
gdata: the location of a valid perl intrpreter.
gdata:
gdata: (To avoid display of this message in the future, please ensure perl is installed and available on the
gdata: executable search path.)
gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLX' (Excel 97-2004) files.

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLSX' (Excel 2007+) files.

gdata: Run the function 'installXLSXsupport()'
gdata: to automatically download and install the perl
gdata: libaries needed to support Excel XLS and XLSX formats.

Attaching package: ‘gdata’

The following object is masked from ‘package:stats’:

nobs

The following object is masked from ‘package:utils’:

object.size

Error in library(lubridate) : there is no package called ‘lubridate’

Sidebar - add options for repeated measures

Add a checkbox "Repeated measures exist". Checked by default. If unchecked, the "measurement" variable selected on GUI is ignored and its selection hidden and a custom "measurement" variable is created, where the values for all units are the same (we have a single measurement occasion).

The units with multiple measurement (those with multiple lines in the data file) are filtered out of the set, since we do not know what to do with them. A warning is generated on the existence of such units and placed in an appropriate tab ("Errors"?).

Checkbox should be positioned between the Date and Measurement inputs on the sidebar.

Add a static picture to be generated

Add a static picture to be generated with plotTests (PDF and/or JPG), additionally to the SVG picture.
Maybe could be done as a parameter in Excel file, that a user can set..

Simplify the calling

We might define such a function:

medplotOnline=function(){
runApp(file.path(path.package("medplot"), "shinyapp_symptoms2" ))}

than the user just needs to call within R to open the browser - seen something (probably) similar in the diversity paper. ANy better ideas/ or already shiny-bilt-in variants?

medplotOnline()

Clustering - add annotations to the graphs

Implement annotations on the clustering graphs. Add multiple selectInput control to select variables to be used. Show only variables, that are not selected as "symptoms".

For code see code sent by Lara, already implementing this. (see part "annotation=data.frame...", uiOutput("clusteringUIAnnotation")).

Only grouping variable should be selected by default.

Create graph 2 on separate tab

The user can choose (via data entry on the tab) what kind of intervals will be used on this tab for plotting data.

Firstly, the user chooses how many intervals he wishes to have.
Secondly he chooses the limits of these intervals.
The data gets a special tag describing to which interval it belongs. Graphs are generated for each of the tags separately.

The graphs are already in "existence", but have to be modified to fit the particular function.

@llaarraa : Please copy-paste the relevant code into this issue and reassign it back to me.

making the results downloadable

what is downloadable? Should we make some of the results explicity downloadable. Or just say in the paper that the user can copy the outputs? We will have to mention it in the paper

positivity threshold

Now we have a default option for positivity of the variables, which is ok.

I would like to add an option in which the user says that he/she is not interested in using a thresholding value, and would therefore want to use ONLY the features related to numerical variables

like: add a checkbox in which he says something like: the variables should not be categorized . If he selects this option some of the tabs are not usable anymore - gets a printed message in all the tabs where variables are categorized saying The analyses included in this tab are available for categorical data only.

IN general: we have to think about how to deal with this issue. THe type of data that we are using as demo data are such that it is quite natural to use them in both ways/ categorical and numerical, but in general this would not be the case. How to deal with this?

Also, a user might also simply add data which are from the start categorical - and do not need further thresholding - Maybe add an additional checkbox saying:

My variables (as imported) are categorical
My variables (as imported) are numerical but I would like to categorize them using a positivity threshold of ....
My variables are numerical and should not be categorized

Terminology change

Change: Choose symptoms (left sidebar) in Choose variables to analyze. Would change everywhere: symptoms to variables (or other appropriate denomination??)

Timeline - add ploting of values of zero

At the moment zero values don't plot on the graph. Add their ploting with a special character (perhaps * or something that plots in the middle of the circle) at the date of the occurrence.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.