{"id":32437218,"url":"https://github.com/wvictor14/plomics","last_synced_at":"2026-07-16T09:02:09.558Z","repository":{"id":169200894,"uuid":"123648558","full_name":"wvictor14/plomics","owner":"wvictor14","description":"Personal library for analyzing genomic data... ","archived":false,"fork":false,"pushed_at":"2019-06-19T00:08:27.000Z","size":3641,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-26T00:00:55.355Z","etag":null,"topics":["27","450k","analysis","array","dna","dnam","epic","methylation"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wvictor14.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-03-03T01:29:27.000Z","updated_at":"2023-11-27T08:20:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"eae1818b-2852-4a97-8731-accac58f215f","html_url":"https://github.com/wvictor14/plomics","commit_stats":null,"previous_names":["wvictor14/plomics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wvictor14/plomics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvictor14%2Fplomics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvictor14%2Fplomics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvictor14%2Fplomics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvictor14%2Fplomics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wvictor14","download_url":"https://codeload.github.com/wvictor14/plomics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wvictor14%2Fplomics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35537751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-16T02:00:06.687Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["27","450k","analysis","array","dna","dnam","epic","methylation"],"created_at":"2025-10-25T23:59:42.516Z","updated_at":"2026-07-16T09:02:09.553Z","avatar_url":"https://github.com/wvictor14.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: \"plomics\"\noutput: \n    github_document:\n        toc: true\n        toc_depth: 3\neditor_options: \n  chunk_output_type: console\n---\n\nA collection of functions for placental DNA methylation analysis.\n\n## Install\n\n```{r message = F, eval = F}\nremotes::install_github('wvictor14/plomics')\n```\n\n```{r, message = F, warning = F, include = F}\nlibrary(plyr)\nlibrary(tidyr)\nlibrary(dplyr)\nlibrary(ggplot2)\n```\n\n## Functions\n\n### lmmatrix\n\nComputes pairwise linear models between several variables.\n\n```{r message = F}\nlibrary(minfiData)\nlibrary(plomics)\n\n# load example data\ndata(RGsetEx)\n\n# calculate pcs on the data\nbetas \u003c- getBeta(RGsetEx)\npc_obj \u003c- prcomp(t(na.omit(betas)), center = T, scale = T)\n\n# get pc scores for each sample\nrotated \u003c- pc_obj$x\n\n#rsquared\nrsq \u003c- lmmatrix(dep = rotated,\n                ind = as.data.frame(pData(RGsetEx)[,c('Sample_Group', 'age', 'sex', 'status')]))\n\n#pvalue\npva \u003c- lmmatrix(dep = rotated,\n                ind = as.data.frame(pData(RGsetEx)[,c('Sample_Group', 'age', 'sex', 'status')]),\n                metric = 'Pvalue')\n##### plot\n# reshape first\nrsq_plot \u003c- rsq %\u003e% as.data.frame() %\u003e% \n  \n  # add dep variables\n  mutate(dep = rownames(rsq)) %\u003e%\n  \n  # reshape\n  gather(PC, rsquared, -dep)\n\npva_plot \u003c- pva %\u003e% as.data.frame() %\u003e% \n  \n  # add dep variables\n  mutate(dep = rownames(rsq)) %\u003e%\n  \n  # reshape\n  gather(PC, pval, -dep) %\u003e%\n  \n  # pvalue categories\n  mutate(pval_cat = case_when(\n    pval \u003e 0.05  ~ '\u003e 0.05',\n    pval \u003c 0.05 \u0026 pval \u003e 0.01 ~ '\u003c 0.05',\n    pval \u003c 0.01 \u0026 pval \u003e 0.001 ~ '\u003c 0.01',\n    pval \u003c 0.001 ~ '\u003c 0.001'\n  ))\n  \nggplot(rsq_plot, aes(x = PC, y = dep, fill = rsquared)) +\n  geom_tile() + theme_bw() +\n  scale_x_discrete(expand = c(0, 0)) +\n  scale_y_discrete(expand = c(0, 0)) +\n  scale_fill_gradientn(colours=c(\"white\", \"#ffffcc\", \"#41b6c4\", \"#2c7fb8\", \"#253494\"), \n                       breaks = c(0,0.5,1), limits = c(0,1), \n                       guide = guide_colorbar(frame.colour = \"black\", ticks.colour = \"black\")) \nggplot(pva_plot, aes(x = PC, y = dep, fill = pval_cat)) +\n  geom_tile() + theme_bw() +\n  scale_x_discrete(expand = c(0, 0)) +\n  scale_y_discrete(expand = c(0, 0)) +\n  scale_fill_manual(values = c('\u003e 0.05' = 'white', '\u003c 0.05' = '#fee8c8', \n                               '\u003c 0.01' = '#fdbb84', '\u003c 0.001' = '#e34a33'))\n```\n\n### pairTest\n\nTo test if covariates are confounding each other, we need to pairwise tests of independence between\ncovariates. If at least one covariate is numeric, we can use linear regression. Otherwise if both\ncovariates are categorical, then a chi squared test must be used.\n\n```{r, warning = F}\nvariables \u003c- data.frame(\n  row = c(1, 1, 2, 2, 3, 3),\n  column = c(1, 1, 1, 2, 2, 2),\n  Sex = c('m', 'm', 'm', 'f', 'f', 'f'),\n  age = c(18, 19, 18, 27, 30, 16),\n  ethnicity = c('AF', 'AF', 'AF', 'EU', 'EU', 'AS')\n)\n\ntests \u003c- pairtest(variables)\n# make categories\ntests \u003c- tests %\u003e% \n  mutate(pval_cat = if_else(p.value \u003c 0.001, '\u003c 0.001',\n                            if_else(p.value \u003c 0.01, '\u003c 0.01',\n                                    if_else(p.value \u003c 0.05, '\u003c 0.05', '\u003c1'))))\ntests\n\n# plot heatmap of associations\nggplot(tests, aes(x=Row, y = Column, fill = pval_cat)) +\n  geom_tile(col = 'grey') + theme(panel.background = element_blank()) + \n  scale_x_discrete(expand = c(0, 0)) +\n  scale_y_discrete(expand = c(0, 0)) +\n  scale_fill_manual(values = c('\u003e 0.05' = 'white', '\u003c 0.05' = '#fee8c8', \n                               '\u003c 0.01' = '#fdbb84', '\u003c 0.001' = '#e34a33'))\n```\n\n### findsentrix\n\n`findsentrix` takes a vector of sentrix IDs (chip identifiers) and searches a directory for IDAT \nfiles that match. The returned data frame contains two columns: (1) the sentrix ID (2) unique file \npaths for each idat that matches the sentrix ID. \n\nHere is an example using the robinson lab master sample sheet:\n\n```{r}\n# read in master sample sheet\nss \u003c- readxl::read_xlsx('Z:/ROBLAB6 Infinium450k John/Master_Sample_Sheet.xlsx')\n\n## specify idat directory\nidat_dir \u003c- 'Z:/ROBLAB6 Infinium450k John/EPIC Raw data/'\n\nss \u003c- ss %\u003e% \n\n# Take the first 6 EPIC samples\n  dplyr::arrange(desc(Platform)) %\u003e% \n  dplyr::slice(1:6) %\u003e% \n  dplyr::select(Sample_Name, Sentrix_ID, Sentrix_Position) %\u003e%\n \n# create sentrix column\n  dplyr::mutate(Sentrix = paste0(Sentrix_ID, '_', Sentrix_Position))\n```\n\nWe created a sentrix ID by taking the chip serial number (confusingly named as \"sentrix_ID\") and \npasting this to the position identifier (\"Sentrix_Position\"):\n\n**Sentrix:** `r ss$Sentrix[1]`\n\n**Sentrix Chip Number:** `r as.character(ss$Sentrix_ID[1])`\n\n**Sentrix Position on chip:** `r ss$Sentrix_Position[1]`\n\n\nNow we can use `findsentrix` to find the filepaths for idats that match each sentrix identifier:\n\n```{r}\nidatfiles \u003c- findsentrix(sentrix = ss$Sentrix, directory = idat_dir)\nidatfiles\n\n# join all matches, retaining unmatched and multiple matched IDs\nss \u003c- ss %\u003e%\n  dplyr::full_join(idatfiles, by = 'Sentrix')\n```\n\nFinally, we can load idats using this dataframe:\n\n```{r}\n## Now you can load in these samples with minfi::read.metharray.exp\nrgset \u003c- minfi::read.metharray.exp(targets = as.data.frame(ss), verbose = T)\nrgset\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwvictor14%2Fplomics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwvictor14%2Fplomics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwvictor14%2Fplomics/lists"}