Skip to content

Commit

Permalink
Version 1.0.8 - Add Rpackages
Browse files Browse the repository at this point in the history
  • Loading branch information
tlesluyes committed Feb 20, 2024
1 parent 0d802b9 commit 1f2a0ec
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 3 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: myFun
Type: Package
Title: myFun is a collection of my favorite R functions, packaged for simplicity
Version: 1.0.7
Date: 2023-01-08
Version: 1.0.8
Date: 2024-02-20
Authors@R: person("Tom", "Lesluyes", email = "[email protected]", role = c("aut", "cre"))
Author: Tom Lesluyes [aut, cre]
Maintainer: Tom Lesluyes <[email protected]>
Expand All @@ -18,6 +18,7 @@ Imports:
GenomicRanges,
IRanges,
doParallel,
foreach
foreach,
rvest
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(Rpackages)
export(adjustPositions)
export(checkGRlist)
export(computeBAF)
Expand All @@ -20,4 +21,5 @@ export(reestimate_ploidy)
export(reestimate_purity)
export(splitDF)
export(summarise_segmetation)
importFrom(foreach,"%do%")
importFrom(foreach,"%dopar%")
36 changes: 36 additions & 0 deletions R/Rpackages.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#' @title Rpackages
#' @description List installed packages and determine their source
#' @details This function lists installed packages and determine whether they are base packages or come from CRAN/Bioconductor or if they are external (GitHub, SourceForge, etc.). This function requires an internet connection.
#' @param CRAN_URL the CRAN URL (default: "http://cran.us.r-project.org")
#' @param Bioconductor_URL the Bioconductor URL (default: "https://www.bioconductor.org/packages/release/bioc/")
#' @return A data.frame with the installed packages and an additional column: Source (possible values: Base, CRAN, Bioconductor, External)
#' @examples head(Rpackages())
#' @author tlesluyes
#' @export
Rpackages=function(CRAN_URL="http://cran.us.r-project.org",
Bioconductor_URL="https://www.bioconductor.org/packages/release/bioc/") {
# Pick CRAN packages
CRAN=as.data.frame(available.packages(repos=CRAN_URL))[, c("Package"), drop=FALSE]
CRAN$Source="CRAN"
# Pick Bioconductor packages
url=url(Bioconductor_URL, "rb")
Bioconductor=as.data.frame(rvest::html_table(rvest::read_html(url))[[1]])[, c("Package"), drop=FALSE]
close(url)
Bioconductor$Source="Bioconductor"
# Pick installed packages
myPackages=as.data.frame(installed.packages())
# Determine the source of each installed package
myPackages$Source=foreach::foreach(i=myPackages$Package, .combine=c) %do% {
# Test whether it is from CRAN and/or Bioconductor
FROM=c(ifelse(i %in% CRAN$Package, "CRAN", NA),
ifelse(i %in% Bioconductor$Package, "Bioconductor", NA))
FROM=FROM[!is.na(FROM)]
# If it is not from CRAN or Bioconductor, test whether it is a base package
if (length(FROM)==0 && i %in% c("base", "compiler", "datasets", "grDevices", "graphics", "grid", "methods", "parallel", "splines", "stats", "stats4", "tcltk", "tools", "utils")) FROM="Base"
# Otherwise, it looks like an external package
if (length(FROM)==0) FROM="External"
# The collapse is needed if a package exists in both CRAN and Bioconductor (not sure this could happen though)
return(paste0(FROM, collapse="/"))
}
return(myPackages)
}
1 change: 1 addition & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#' @importFrom foreach %dopar%
#' @importFrom foreach %do%
NULL
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,17 @@ summarise_segmetation(DF, "chr", "pos", "pos", c("logR", "BAF"))
#
# $IDs$`5`
# [1] "SNP_14" "SNP_15" "SNP_16"
```

### Where do my packages come from?
```R
Rpackages()
# Package ... Source
# abind abind ... CRAN
# aCGH aCGH ... Bioconductor
# affxparser affxparser ... Bioconductor
# affy affy ... Bioconductor
# affyio affyio ... Bioconductor
# anndata anndata ... CRAN
# ...
```
31 changes: 31 additions & 0 deletions man/Rpackages.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified manual/myFun.pdf
Binary file not shown.

0 comments on commit 1f2a0ec

Please sign in to comment.