Skip to content
Snippets Groups Projects
Commit 160cf254 authored by anjuraj15's avatar anjuraj15
Browse files

Create PCL_CCS_merge.R

Add PCL_CCS_merge.R: Merge CCS values to PubChemLite exposomics file
parent 3bf8ab4b
No related branches found
No related tags found
No related merge requests found
## Copyright (C) 2020 by University of Luxembourg
## Rscript : PCL_CCS_merge.R
## Add CCS to PubChemLite exposomics file.
## Input : pubchemlite_ccs.csv, Pubchemlite_exposomics.csv
pcl <- read.csv("PubChemLite_exposomics_20240329.csv", check.names = FALSE)
ccs <- read.csv("pubchemlite_CCS_20240410.csv", check.names = FALSE)
# Define the columns to be extracted from ccs
#ccs_columns <- ccs[,c(1,5:12)] # Columns 5 to 12 in ccs
# Create a lookup table from ccs with "cid" and selected columns
lookup_table <- ccs[,c(1,5:12)]
# Merge the lookup table with pcl based on "identifier" and "cid"
merged_data <- merge(pcl, lookup_table, by.x = "Identifier", by.y = "cid", all.x = TRUE)
# Define new column names corresponding to the selected columns from ccs
new_column_names <- c(
"pred_CCS_A2_[M+H]+",
"pred_CCS_A2_[M+Na]+",
"pred_CCS_A2_[M+NH4]+",
"pred_CCS_A2_[M+K]+",
"pred_CCS_A2_[M-H]-",
"pred_CCS_A2_[M+Na-2H]-",
"pred_CCS_A2_[M]+",
"pred_CCS_A2_[M]-"
)
# Assign new column names to the extracted columns in merged_data
colnames(merged_data)[(ncol(merged_data) - length(new_column_names) + 1):ncol(merged_data)] <- new_column_names
# Write the updated data to a new CSV file
write.csv(merged_data, "PubChemLite_CCSbase_20240329.csv", row.names = FALSE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment