Giter Site home page Giter Site logo

xgx's People

Contributors

faribas avatar iamstein avatar margoal1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xgx's Issues

Create Rmarkdown Tips page

There are lots of little tips I find and always forget and thought it'd be nice to compile them in a page. It could be another Resource. Pasting a bit of it below to give you an idea.


title: Rmarkdown Tips
author: "Andy Stein"
date: "r format(Sys.time(), '%d %B, %Y')"
output:
bookdown::html_document2:
toc: yes
toc_float: yes
code_folding: hide
bibliography: Bibliography.bib

Common Errors

  • Don't name code chunks with special characters (especially underscores), because cross-referencing will not work.

Header - Default

---
title: YOUR TITLE
author: "YOUR NAME"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  bookdown::html_document2:
    toc: yes
    toc_float: yes
    code_folding: hide
bibliography: Bibliography.bib
---

Text

Displaying messages and warnings by default

knitr::opts_chunk$set(warning = FALSE, message = FALSE)

Number of digits to display in inline code by default

knitr::knit_hooks$set(inline = function(x) {
  x <- sprintf("%1.2", x)
  paste(x, collapse = ", ")
})

Figures

Set default size

knitr::opts_chunk$set(fig.height = 4, fig.width = 8)

How to cross-reference and add caption

Tables

data.table vs kable

Set default number of rows

Change number of rows

How to cross-reference and add caption

References


set.seed(123)

#set chunk default options
knitr::opts_chunk$set(warning = FALSE, message = FALSE, fig.height = 4, fig.width = 8)

# Output only 2 significant digits for inline r outputs
knitr::knit_hooks$set(inline = function(x) {
  x <- sprintf("%1.2g", x)
  paste(x, collapse = ", ")
})

xgx_scale_y_percentchangelog10 issues

I found a couple issues with xgx_scale_y_percentchangelog10().

  1. There aren't enough ticks between 0-100%
  2. The limits option seems to have different behavior for negative and positive numbers

`
data_example = data.frame(x = 1, y = seq(-.9, 1, by = 0.1))
g = ggplot(data = data_example, aes(x = x, y = y))
g = g + geom_point()
g = g + xgx_scale_y_percentchangelog10(limits = c(-90,1))
g = g + ggtitle("aren't enough ticks between 0-100% and also, the limits setting is weird - c(-90,1)")
print(g)

g = g + xgx_scale_y_percentchangelog10(limits = c(-90,100))
g = g + ggtitle("limits aren't what I expected, and labels are weird")
print(g)
`
image

Add more information to Rmarkdowns - author and date

html - indent once
next lines - indent twice

title: "CTL019B2202, CTL019B2205J, CTL019C2201 ROW PK Data Exploration"
author: "Andy Stein"
date: "r format(Sys.time(), '%d %B, %Y')"
output:
html_document:
toc: true
toc_float: true
code_folding: hide

exposure response

I could not reproduce the figure in the code on the website
https://opensource.nibr.com/xgx/Multiple_Ascending_Dose_PKPD_binary.html

pkpd_data_wide_plot = pkpd_data_wide %>%
mutate(PROFDAY_STR = paste("Day",PROFDAY)) %>%
filter(PROFDAY %in% c(1,3,5)) %>%
mutate(CONC_QUART = cut(CONC, quantile(CONC, na.rm=TRUE), na.rm=TRUE, include.lowest = TRUE)) %>%
group_by(CONC_QUART) %>%
mutate(CONC_MIDPOINT = median(CONC))

gg <- ggplot(data = pkpd_data_wide_plot, aes(x = CONC, y = PD))
gg <- gg + geom_jitter(aes(color = TRTACT_high2low), width = 0, height = 0.05, alpha = 0.5)
gg <- gg + geom_smooth(method = "glm", method.args = list(family=binomial(link = logit)), color = "black")
gg <- gg + xgx_stat_ci(aes(x = CONC_MIDPOINT, y = PD), distribution = "binomial", geom = "errorbar", size = 0.5)
gg <- gg + xgx_stat_ci(aes(x = CONC_MIDPOINT, y = PD), distribution = "binomial", geom = "point", shape = 0, size = 4)
gg <- gg + scale_y_continuous(labels=scales::percent)
gg <- gg + labs(x = conc_label, y = pd_response_label, color = trtact_label)
gg <- gg + xgx_scale_x_log10()
gg <- gg + facet_grid(~PROFDAY_STR)
print(gg)

After I plot, it miss the error bar and points on the curve, it looks like below:
image

switch from xgx_annotate_filenames to labs(caption = caption) for simplicity/transparency

At the top of my code, I have something like:

caption = paste(c("Parent Dir: dosefindingtoolbox/Rmarkdown",
                  "Rmarkdown: Efficacy_Data_Overview_Plots.Rmd",
                  "Output: Efficacy_Data_Overview_Plots.html",
                  paste0("Timestamp: ", Sys.time())),
                collapse = "\n")

And then when Iโ€™m building the graphic, I have this:

g = g + labs(caption = caption)

Or another idea is at the top of the code to type something like

gcaption = theme(plot.caption = element_text(hjust = 0.5)) +
      labs(caption = paste0(dirs$top.local,"\n",
                            file.path(dirs$scripts.local, Rname),"\n",
                            file.path(dirs$scripts.local, Rmd_In),"\n",
                            file.path(dirs$results.local, Rmd_Out)))

then, later on in the code you can use

g = g + gcaption

xgx_scale_y_percentchangelog10() + geom_jitter() has problems with -100%

Hey @margoal1, the -100% (-1) points disappear when using geom_jitter(), but not when using geom_point(). Compare the two plots below. I'm not sure if this is xgx's fault or ggplot2's fault, but just wanted to raise the issue.

data = data.frame(x = c(0, 0, 1, 1, 2, 2), y = c(1, 0, -1, -.5, -1, -1))
ggplot(data, aes(x = x, y = y)) + geom_point() + xgx_scale_y_percentchangelog10()
ggplot(data, aes(x = x, y = y)) + geom_jitter(height = 0, width = 0) + xgx_scale_y_percentchangelog10()

xgx_bug

Data Checking Page

The code for detecting continuous covariates only relies on there being >= 8 unique values. But it should also be added to the check that the variable is numeric. In some cases, categorical variables can have >= 9 unique values, if it happens where the column is a string, it causes an error in teh continuous variable data processing further down.

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.