{"id":16572269,"url":"https://github.com/jonocarroll/dfplyr","last_synced_at":"2025-03-16T20:31:22.264Z","repository":{"id":71014033,"uuid":"226102443","full_name":"jonocarroll/DFplyr","owner":"jonocarroll","description":"A `DataFrame` (`S4Vectors`) backend for `dplyr`","archived":false,"fork":false,"pushed_at":"2024-10-16T04:35:32.000Z","size":198,"stargazers_count":21,"open_issues_count":4,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-12T14:50:44.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonocarroll.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2019-12-05T12:56:14.000Z","updated_at":"2024-10-29T19:02:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"c159239e-7895-4e8b-ae09-ae42ddaf3523","html_url":"https://github.com/jonocarroll/DFplyr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2FDFplyr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2FDFplyr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2FDFplyr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2FDFplyr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonocarroll","download_url":"https://codeload.github.com/jonocarroll/DFplyr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830912,"owners_count":20354848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-11T21:26:57.322Z","updated_at":"2025-03-16T20:31:21.777Z","avatar_url":"https://github.com/jonocarroll.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n    collapse = TRUE,\n    comment = \"#\u003e\",\n    fig.path = \"man/figures/README-\",\n    out.width = \"100%\"\n)\n```\n# DFplyr\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nThe goal of DFplyr is to enable `dplyr` and `ggplot2` support for\n`S4Vectors::DataFrame` by providing the appropriate extension methods. As row\nnames are an important feature of many Bioconductor structures, these are\npreserved where possible.\n\n## Installation\n\nYou can install the development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"jonocarroll/DFplyr\")\n```\n\nYou can install from [Bioconductor](https://bioconductor.org) with:\n\n``` r\nif (!require(\"BiocManager\", quietly =TRUE))\n    install.packages(\"BiocManager\")\n\n# The following initializes usage of Bioc devel\nBiocManager::install(version='devel')\n\nBiocManager::install(\"DFplyr\")\n```\n\n## Examples\n\nFirst create an S4Vectors `DataFrame`, including S4 columns if desired\n\n```{r}\nlibrary(S4Vectors)\nm \u003c- mtcars[, c(\"cyl\", \"hp\", \"am\", \"gear\", \"disp\")]\nd \u003c- as(m, \"DataFrame\")\nd$grX \u003c- GenomicRanges::GRanges(\"chrX\", IRanges::IRanges(1:32, width = 10))\nd$grY \u003c- GenomicRanges::GRanges(\"chrY\", IRanges::IRanges(1:32, width = 10))\nd$nl \u003c- IRanges::NumericList(lapply(d$gear, function(n) round(rnorm(n), 2)))\nd\n```\n\nThis will appear in RStudio's environment pane as a \n\n```\nFormal class DataFrame (dplyr-compatible)\n``` \n\nwhen using `DFplyr`. No interference with the actual object is required, but\nthis helps identify that `dplyr`-compatibility is available.\n\n`DataFrame`s can then be used in `dplyr` calls the same as `data.frame` or\n`tibble` objects. Support for working with S4 columns is enabled provided they\nhave appropriate functions. Adding multiple columns will result in the new\ncolumns being created in alphabetical order\n\n```{r}\nlibrary(DFplyr)\n\nmutate(d, newvar = cyl + hp)\n\nmutate(d, nl2 = nl * 2)\n\nmutate(d, length_nl = lengths(nl))\n\nmutate(d,\n    chr = GenomeInfoDb::seqnames(grX),\n    strand_X = BiocGenerics::strand(grX),\n    end_X = BiocGenerics::end(grX)\n)\n```\n\nthe object returned remains a standard `DataFrame`, and further calls can be \npiped with `%\u003e%`\n\n\n```{r}\nmutate(d, newvar = cyl + hp) %\u003e%\n    pull(newvar)\n```\n\nSome of the variants of the `dplyr` verbs also work\n\n```{r}\nmutate_if(d, is.numeric, ~ .^2)\n\nmutate_if(d, ~ inherits(., \"GRanges\"), BiocGenerics::start)\n```\n\nUse of `tidyselect` helpers is limited to within `dplyr::vars()` calls and using \nthe `_at` variants\n\n```{r}\nmutate_at(d, vars(starts_with(\"c\")), ~ .^2)\n\nselect_at(d, vars(starts_with(\"gr\")))\n```\n\nImportantly, grouped operations are supported. `DataFrame` does not \nnatively support groups (the same way that `data.frame` does not) so these\nare implemented specifically for `DFplyr`\n\n```{r}\ngroup_by(d, cyl, am)\n```\n\nOther verbs are similarly implemented, and preserve row names where possible\n\n```{r}\nselect(d, am, cyl)\n\narrange(d, desc(hp))\n\nfilter(d, am == 0)\n\nslice(d, 3:6)\n\ngroup_by(d, gear) %\u003e%\n    slice(1:2)\n```\n\n`rename` is itself renamed to `rename2` due to conflicts between {dplyr} and \n{S4Vectors}, but works in the {dplyr} sense of taking `new = old` replacements \nwith NSE syntax\n\n```{r}\nselect(d, am, cyl) %\u003e%\n    rename2(foo = am)\n```\n\nRow names are not preserved when there may be duplicates or they don't make\nsense, otherwise the first label (according to the current de-duplication\nmethod, in the case of `distinct`, this is via `BiocGenerics::duplicated`). This\nmay have complications for S4 columns.\n\n```{r}\ndistinct(d)\n\ngroup_by(d, cyl, am) %\u003e%\n    tally(gear)\n\ncount(d, gear, am, cyl)\n```\n\n## Coverage\n\nMost `dplyr` functions are implemented with the exception of `join`s. \n\nIf you find any which are not, please [file an issue](https://github.com/jonocarroll/DFplyr/issues/new).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Fdfplyr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonocarroll%2Fdfplyr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Fdfplyr/lists"}