This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(curatedMetagenomicData) | |
library(dplyr) | |
library(table1) | |
dat <- sampleMetadata |> | |
select(study_name, body_site, study_condition, age_category, age, BMI) | |
# labeling is optional, just to make the table nicer | |
label(dat$body_site) <- "Body Site" | |
label(dat$study_condition) <- "Study Condition" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(nabor) | |
# suppose you have two vectors of propensity scores | |
propensity_scores1 <- c(0.1, 0.2, 0.3, 0.4, 0.5) #more controls | |
propensity_scores2 <- c(0.15, 0.25, 0.35) #fewer cases | |
# use the knn function from the nabor package to find the index of the closest match in propensity_scores2 for each score in propensity_scores1 | |
matches <- nabor::knn(matrix(propensity_scores2), matrix(propensity_scores1), k = 1)$nn.idx | |
# print the matches |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(curatedMetagenomicData) | |
library(dplyr) | |
agecats <- unique(sampleMetadata$age_category) |> na.omit() | |
sm <- filter(sampleMetadata, study_condition=="control") |> | |
filter(disease == "healthy") |> | |
filter(body_site == "stool") |> | |
filter(!is.na(age_category)) | |
for (agecat in agecats){ | |
sm1 <- filter(sm, age_category == agecat) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suppressPackageStartupMessages({ | |
library(lefser) | |
library(curatedMetagenomicData) | |
}) | |
zeller <- | |
curatedMetagenomicData("ZellerG_2014.pathway_abundance", | |
counts = TRUE, | |
dryrun = FALSE)[[1]] | |
zeller <- zeller[, zeller$study_condition != "adenoma"] | |
zeller <- relativeAb(zeller) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suppressPackageStartupMessages({ | |
library(curatedMetagenomicData) | |
library(mia) | |
library(dplyr) | |
library(purrr) | |
}) | |
datasets <- sampleMetadata |> | |
group_by(study_name) |> | |
count() |> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before using this script you need to create an OpenAI API key (https://platform.openai.com/api-keys) | |
and put it in ~/.Renviron: | |
OPENAI_API_KEY='my_key_here' | |
# libraries used | |
library(openai) | |
library(dplyr) | |
library(stringr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(bugsigdbr) | |
bsdb <- importBugSigDB(version = "devel") | |
# Create a stacked barplot of the proportion of Pielou, Shannon, Chao1, Simpson, Inverse Simpson, and Richness as a function of year | |
library(tidyverse) | |
bsdb_by_year <- bsdb |> | |
filter(Year > 2014) |> | |
dplyr::group_by(Year) |> | |
dplyr::summarize( | |
Pielou = sum(!is.na(Pielou)) / n(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Stepwise treadmill test" | |
author: "Levi Waldron" | |
date: "`r Sys.Date()`" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% \VignetteIndexEntry{Using Affymetrix Probe Level Data} | |
% \VignetteDepends{hgu95av2.db, rae230a.db, rae230aprobe, Biostrings} | |
% \VignetteKeywords{Annotation} | |
%\VignettePackage{annotate} | |
\documentclass{article} | |
\newcommand{\Rfunction}[1]{{\texttt{#1}}} | |
\newcommand{\Rmethod}[1]{{\texttt{#1}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suppressPackageStartupMessages(library(curatedMetagenomicData)) | |
zeller <- curatedMetagenomicData::curatedMetagenomicData("Zeller.+relative_abundance", counts = FALSE, dryrun = FALSE)[[1]] | |
zellercounts <- curatedMetagenomicData::curatedMetagenomicData("Zeller.+relative_abundance", counts = TRUE, dryrun = FALSE)[[1]] | |
zeller <- zeller[, zeller$study_condition != "adenoma"] | |
zellercounts <- zellercounts[, zellercounts$study_condition != "adenoma"] | |
suppressPackageStartupMessages(library(lefser)) | |
res_group <- lefser(zeller, groupCol = "study_condition") | |
res_group_counts <- lefser(zellercounts, groupCol = "study_condition") |
NewerOlder