KlugerLab / ALRA

Imputation method for scRNA-seq based on low-rank approximation
MIT License
73 stars 19 forks source link

Turn ALRA into a package #23

Closed rcannood closed 1 year ago

rcannood commented 1 year ago

Hi @linqiaozhi !

To make ALRA a little easier to use, I turned the repo into an R package. I documented the process below.

I suggest editing the DESCRIPTION to fill in the placeholder fields generated by usethis::create_package().

Kind regards, Robrecht

Instructions used to turn this repo into a package

Create a package

usethis::create_package("ALRA")
✔ Setting active project to '/path/to/ALRA'
✔ Creating 'R/'
✔ Writing 'DESCRIPTION'
Package: ALRA
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R (parsed):
    * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID)
Description: What the package does (one paragraph).
License: `use_mit_license()`, `use_gpl3_license()` or friends to
    pick a license
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2
✔ Writing 'NAMESPACE'

Add dependencies

# if you don't have rsvd installed first
# install.packages("rsvd")
usethis::use_package("rsvd")
✔ Adding ‘rsvd’ to Imports field in DESCRIPTION • Refer to functions
with `rsvd::fun()`
# if you don't have fastRPCA installed, follow the instructions at
# https://github.com/KlugerLab/rpca-mkl#r-package-installation

# add to dependencies
usethis::use_dev_package("fastRPCA", "Suggests", remote = "github::KlugerLab/rpca-mkl/fastRPCA")
✔ Adding ‘fastRPCA’ to Suggests field in DESCRIPTION 
✔ Adding ‘github::KlugerLab/rpca-mkl/fastRPCA’ to Remotes field in DESCRIPTION

Move the source files

fs::file_move(c("alra.R", "alraSeurat2.R"), "R")

Download the example data files

b_nk_example <- readr::read_rds('https://gauss.math.yale.edu/~gcl22/alra/b_nk_example.RDS')
usethis::use_data(b_nk_example)
✔ Adding 'R' to Depends field in DESCRIPTION
✔ Setting LazyData to 'true' in 'DESCRIPTION'
✔ Saving 'b_nk_example' to 'data/b_nk_example.rda'
• Document your data (see 'https://r-pkgs.org/data.html')
labels_example <- readr::read_rds('https://gauss.math.yale.edu/~gcl22/alra/labels_example.RDS')
usethis::use_data(labels_example)
> usethis::use_data(labels_example)
✔ Saving 'labels_example' to 'data/labels_example.rda'
• Document your data (see 'https://r-pkgs.org/data.html')

Create unit test

usethis::use_test("alra_test")
✔ Adding 'testthat' to Suggests field in DESCRIPTION
✔ Setting Config/testthat/edition field in DESCRIPTION to '3'
✔ Creating 'tests/testthat/'
✔ Writing 'tests/testthat.R'
✔ Writing 'tests/testthat/test-alra_test.R'
• Modify 'tests/testthat/test-alra_test.R'

Further processing

I adapted the alra_test.R into a unit test. You can run all unit tests using:

devtools::test()

I turned the documentation into roxygen code and ran devtools::document() to generate the man/ files.

devtools::document()

After this, I ran R CMD check a couple of times to fix minor issues.

rcmdcheck::rcmdcheck()
ryandward commented 1 year ago

What are we waiting for? @rcannood in the essence of getting things to move, I've just used this in my code. Please don't break it :)


install.packages("devtools")
devtools::install_github("rcannood/ALRA")
rcannood commented 1 year ago

Please don't break it :) @ryandward I won't ^^

@JunZhao1990 @linqiaozhi Could I kindly ask you to review this PR? It effectively turns the code in the ALRA repo into a package that allows people to use ALRA.

linqiaozhi commented 1 year ago

@rcannood Really embarrassed to be responding so late. My clinical duties have been pretty all-consuming. This is excellent. Thank you so much for working on it.