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
-- Install and load the httpfs extension to read from GCS | |
install httpfs; | |
load httpfs; | |
-- Create a secret for accessing Google Cloud Storage using a JSON key file | |
CREATE SECRET metagenomics_mac ( | |
TYPE GCS, | |
KEY_FILE '/path/to/your/gcp-credentials.json' | |
); |
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: Benchmark Query Performance on Sorted vs. Unsorted Parquet Files | |
# Description: This script first creates a new Parquet file sorted by the | |
# '# Gene Family' column. It then uses the 'microbenchmark' | |
# package to compare the query speed for a specific gene | |
# family between the original, unsorted file and the new, | |
# sorted file. | |
# --- 1. SETUP: Load necessary libraries --- | |
# Ensure you have these packages installed: | |
# install.packages(c("duckdb", "dplyr", "arrow", "microbenchmark")) |
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: "F. prausnitzii in PD" | |
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
--- | |
title: "pMDstudies" | |
author: "Levi Waldron" | |
date: "`r Sys.Date()`" | |
output: html_document | |
--- | |
```{r, message=FALSE, warning=FALSE, echo=FALSE} | |
library(parkinsonsMetagenomicData) | |
library(dplyr) |
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(parkinsonsMetagenomicData)) | |
#> Set default bucket name to 'metagenomics-mac' | |
packageVersion("parkinsonsMetagenomicData") | |
#> [1] '0.0.0.9000' | |
colnames(sampleMetadata) |> sort() | |
#> [1] "Adhesive removal (s)" | |
#> [2] "age" | |
#> [3] "Age" | |
#> [4] "AGE" | |
#> [5] "age_group" |
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() |> |
NewerOlder