clinpubr
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.3%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
Basic Info
- Host: GitHub
- Owner: yotasama
- License: other
- Language: R
- Default Branch: main
- Size: 3.99 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
- Releases: 0
Created over 1 year ago
· Last pushed 10 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
dpi = 300,
fig.path = "man/figures/README-",
out.width = "60%"
)
```
# clinpubr: Clinical Publication
[](https://CRAN.R-project.org/package=clinpubr)
[](https://app.codecov.io/gh/yotasama/clinpubr)
[](https://github.com/yotasama/clinpubr/actions/workflows/R-CMD-check.yaml)
## Overview
`clinpubr` is an R package designed to streamline the workflow from clinical data processing to publication-ready outputs. It provides tools for clinical data cleaning, significant result screening, and generating tables/figures suitable for medical journals.
## Key Features
- **Clinical Data Cleaning**: Functions to handle missing values, standardize units, convert dates, and clean numerical/categorical variables.
- **Result Screening**: Screening results of regression and interaction analysis with common variable transformations to identify key findings.
- **Publication-Ready Outputs**: Generate baseline characteristic tables, forest plots, RCS curves, and other visualizations formatted for medical publications.
## Installation
You can install `clinpubr` from CRAN with:
``` r
install.packages("clinpubr")
```
### Optional Dependencies
Some functions require additional packages for full functionality.
The package will automatically prompt you to install missing packages when needed.
If you want to install the package with all dependencies, you can use:
``` r
install.packages("clinpubr", dependencies = TRUE)
```
## Basic Usage
### Cleaning Tools
#### Example 1.1: Standardize Values in Medical Records
```{r example_1.1}
library(clinpubr)
# Sample messy data
messy_data <- data.frame(values = c("12.3", "0..45", " 67 ", "", "abandon"))
clean_data <- value_initial_cleaning(messy_data$values)
print(clean_data)
```
#### Example 1.2: Check Non-numerical Values
```{r example_1.2}
# Sample messy data
x <- c("1.2(XXX)", "1.5", "0.82", "5-8POS", "NS", "FULL")
print(check_nonnum(x))
```
This function filters out non-numerical values, which helps you choose the
appropriate method to handle them.
#### Example 1.3: Extracting Numerical Values from Text
```{r example_1.3}
# Sample messy data
x <- c("1.2(XXX)", "1.5", "0.82", "5-8POS", "NS", "FULL")
print(extract_num(x))
print(extract_num(x,
res_type = "first", # Extract the first number
multimatch2na = TRUE, # Convert illegal multiple matches to NA
zero_regexp = "NEG|NS", # Convert "NEG" and "NS" (matched using regex) to 0
max_regexp = "FULL", # Convert "FULL" (matched using regex) to some specified quantile
max_quantile = 0.95
))
```
#### Other Cleaning Functions
- *`to_date()`*: Convert text to date, can handle mixed format.
- *`unit_view()`* and *`unit_standardize()`*: Provide a pipeline to standardize conflicting units.
- *`cut_by()`*: Split numerics into factors, offers a variety of splitting options and auto labeling.
- And more...
### Screening Results to Identify Potential Findings
```{r example_2}
data(cancer, package = "survival")
# Screening for potential findings with regression models in the cancer dataset
scan_result <- regression_scan(cancer, y = "status", time = "time", save_table = FALSE)
knitr::kable(scan_result)
```
### Generating Publication-Ready Tables and Figures
#### Example 3.1: Automatic Type Infer and Baseline Table Generation
```{r example_3.1}
var_types <- get_var_types(mtcars, strata = "vs") # Automatically infer variable types
print(var_types)
tables <- baseline_table(mtcars,
var_types = var_types, contDigits = 1, save_table = FALSE,
filename = "baseline.csv", seed = 1 # set seed for simulated fisher exact test
)
knitr::kable(tables$baseline) # Display the table
```
#### Example 3.2: RCS Plot
```{r example_3.2}
data(cancer, package = "survival")
# Performing cox regression, which is inferred by `y` and `time`
p <- rcs_plot(cancer, x = "age", y = "status", time = "time", covars = c("sex", "ph.karno"), save_plot = FALSE)
plot(p)
```
#### Example 3.3: Interaction Plot
```{r example_3.3}
data(cancer, package = "survival")
# Generating interaction plot of both linear and RCS models
p <- interaction_plot(cancer,
y = "status", time = "time", predictor = "age",
group_var = "sex", save_plot = FALSE
)
plot(p$lin)
plot(p$rcs)
```
#### Example 3.4: Regression Forest Plot
```{r example_3.4, fig.height=3}
data(cancer, package = "survival")
cancer$dead <- cancer$status == 2 # Preparing a binary variable for logistic regression
cancer$`age per 1 sd` <- c(scale(cancer$age)) # Standardizing age
# Performing multivairate logistic regression
p1 <- regression_forest(cancer,
model_vars = c("age per 1 sd", "sex", "wt.loss"), y = "dead",
as_univariate = FALSE, save_plot = FALSE
)
plot(p1)
p2 <- regression_forest(
cancer,
model_vars = list(
Crude = c("age per 1 sd"),
Model1 = c("age per 1 sd", "sex"),
Model2 = c("age per 1 sd", "sex", "wt.loss")
),
y = "dead",
save_plot = FALSE
)
plot(p2)
```
#### Example 3.5: Subgroup Forest Plot
```{r example_3.5, out.width = "70%", fig.width = 8, fig.height=4}
data(cancer, package = "survival")
# coxph model with time assigned
p <- subgroup_forest(cancer,
subgroup_vars = c("age", "sex", "wt.loss"), x = "ph.ecog", y = "status",
time = "time", covars = "ph.karno", ticks_at = c(1, 2), save_plot = FALSE
)
plot(p)
```
#### Example 3.6: Classification Model Performance
```{r example_3.6}
# Building models with example data
data(cancer, package = "survival")
df <- kidney
df$dead <- ifelse(df$time <= 100 & df$status == 0, NA, df$time <= 100)
df <- na.omit(df[, -c(1:3)])
model0 <- glm(dead ~ age + frail, family = binomial(), data = df)
model1 <- glm(dead ~ ., family = binomial(), data = df)
df$base_pred <- predict(model0, type = "response")
df$full_pred <- predict(model1, type = "response")
# Generating most of the useful plots and metrics for model comparison
results <- classif_model_compare(df, "dead", c("base_pred", "full_pred"), save_output = FALSE)
knitr::kable(results$metric_table)
plot(results$roc_plot)
plot(results$calibration_plot)
plot(results$dca_plot)
```
#### Example 3.7: Importance Plot
```{r example_3.7}
# Generating a dummy importance vector
set.seed(5)
dummy_importance <- runif(20, 0.2, 0.6)^5
names(dummy_importance) <- paste0("var", 1:20)
# Plotting variable importance, keeping only top 15 and splitting at 10
p <- importance_plot(dummy_importance, top_n = 15, split_at = 10, save_plot = FALSE)
plot(p)
```
## Documentation
For detailed usage, refer to the package vignettes (coming soon) or the [GitHub repository](https://github.com/yotasama/clinpubr).
## Contributing
Bug reports and feature requests are welcome via the [issue tracker](https://github.com/yotasama/clinpubr/issues).
## License
`clinpubr` is licensed under GPL (>= 3).
Owner
- Name: Yue Niu
- Login: yotasama
- Kind: user
- Location: Beijing
- Repositories: 2
- Profile: https://github.com/yotasama
GitHub Events
Total
- Issues event: 4
- Push event: 23
- Create event: 1
Last Year
- Issues event: 4
- Push event: 23
- Create event: 1
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 4
- Total pull requests: 0
- Average time to close issues: about 2 months
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 0
- Average time to close issues: about 2 months
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- yotasama (4)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 293 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
cran.r-project.org: clinpubr
Clinical Publication
- Homepage: https://github.com/yotasama/clinpubr
- Documentation: http://cran.r-project.org/web/packages/clinpubr/clinpubr.pdf
- License: MIT + file LICENSE
-
Latest release: 1.0.2
published 11 months ago
Rankings
Dependent packages count: 26.2%
Dependent repos count: 32.2%
Average: 48.3%
Downloads: 86.5%
Maintainers (1)
Last synced:
10 months ago