novartis / xgx Goto Github PK
View Code? Open in Web Editor NEWExploratory Graphics for PKPD data
Exploratory Graphics for PKPD data
Would be better to specify the continuous and categorical data subsets at the top, directly, instead of the >=8 line.
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.
r format(Sys.time(), '%d %B, %Y')
"---
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
---
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
knitr::knit_hooks$set(inline = function(x) {
x <- sprintf("%1.2", x)
paste(x, collapse = ", ")
})
knitr::opts_chunk$set(fig.height = 4, fig.width = 8)
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 = ", ")
})
Hi,
I checked the R code of "PK-Multiple Ascending Dose" and wonder what does SS_PROFDAY = 6 # steady state prof day
mean? Could you give an example? Thank you for your nice work!
I found a couple issues with xgx_scale_y_percentchangelog10().
`
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)
`
consider custom ggpairs page instead of corrplot
figure out how to add x-label to the missing values plot
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
Try recompiling the website with a fresh R session
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:
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
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()
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.
This package seems to play nicer with ggplot2 (and maybe nicer with xgxr too)
https://cloud.r-project.org/web/packages/ggsurvfit/index.html
A search box can be added with a single line in the _site.yml
file, though I think it also requires filling out description meta-data for each page as well. This is just something we could explore at some point.
Some of the looking at correlations between covariates isn't really checking for issues, it's more part of initial data analysis. it might make more sense to break this into two docs and then have some slightly more thorough IDA based on Dose Finding Toolbox.
For the hazard ratio, the 1.2^beta is not correct. It should be exp(beta*(value2-value1)).
Also, would be good to add forest plot code, too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.