You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
R code to calculate Cosine distance between samples in an IDBac SQLite database:
install.packages(c("remotes", "dplyr", "DBI", "pool", "coop"))
remotes::install_github("chasemc/IDBacApp@*release")
library(IDBacApp)
library(dplyr)
library(DBI)
library(pool)
library(coop)
# Change this to be the full file path to your sqlite file
sqlite_filepath <- tempfile(fileext = ".sqlite")
# don't run the download unless you are just testing
download.file("https://massive.ucsd.edu/ProteoSAFe/DownloadResultFile?file=f.MSV000084291/raw/data/idbac_experiment_file.sqlite", destfile = sqlite_filepath)
db_pool <- IDBacApp::idbac_connect(fileName = tools::file_path_sans_ext(basename(sqlite_filepath)),
filePath = dirname(sqlite_filepath))[[1]]
# Update the database to the latest version
idbac_update_db(pool = db_pool, copy_overwrite = "overwrite")
# Reconnect to the database
db_pool <- IDBacApp::idbac_connect(fileName = tools::file_path_sans_ext(basename(sqlite_filepath)),
filePath = dirname(sqlite_filepath))[[1]]
# Peak at the tables in the SQLite database
sapply(DBI::dbListTables(conn = db_pool),
function(x){
print(dplyr::tbl(db_pool, x ) %>% head())
}, simplify = F)
# Enter your sample IDs here
sample_ids <- c("172-1","172-10","172-11","172-7")
# Adjust the variables for mass cutoffs etc, below
temp <- lapply(sample_ids,
function(ids){
IDBacApp::idbac_get_peaks(pool = db_pool,
sampleIDs = ids,
minFrequency = 0,
minNumber = NA,
lowerMassCutoff=3000,
upperMassCutoff = 15000,
minSNR = 3,
tolerance = 0.002,
type = "protein",
mergeReplicates = TRUE)[[1]]
})
names(temp) <- c(sample_ids)
# Adjust the variables for mass cutoffs etc, below. It's complicated but ppm isn't a direct cutoff, it controls how the peaks are "fuzzified"
fuzzy_vec <- IDBacApp::createFuzzyVector(
massStart =3000,
massEnd = 15000,
ppm = 1000,
massList = lapply(temp, function(x) x@mass),
intensityList = lapply(temp, function(x) x@intensity)
)
# Print distance matrix between samples
stats::as.dist(1 - coop::cosine(fuzzy_vec))
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
R code to calculate Cosine distance between samples in an IDBac SQLite database:
Beta Was this translation helpful? Give feedback.
All reactions