Skip to content

Commit

Permalink
loupeR version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
esiegel committed Sep 12, 2023
0 parents commit 75e4bc8
Show file tree
Hide file tree
Showing 34 changed files with 2,324 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
pull_request:
branches: [main]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: false
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
on:
workflow_dispatch:
inputs:
tag:
description: 'Git Tag/Release that we are uploading to'
required: true

name: release

permissions:
contents: write

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: false

- name: Configure gh for auth
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: gh auth setup-git

- name: Create Exec directory
shell: bash
run: mkdir exec

# Copy Louper binaries to the `exec` directory
- name: Copy Louper binary to Exec directory (Windows)
if: ${{ contains(matrix.config.os, 'windows') }}
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: gh release download ${{ github.event.inputs.tag }} -p 'louper-windows*' -O exec/louper.exe
- name: Copy Louper binary to Exec directory (Linux)
if: ${{ contains(matrix.config.os, 'ubuntu') }}
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: gh release download ${{ github.event.inputs.tag }} -p 'louper-linux*' -O exec/louper
- name: Copy Louper binary to Exec directory (MacOS)
if: ${{ contains(matrix.config.os, 'macos') }}
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: gh release download ${{ github.event.inputs.tag }} -p 'louper-macos*' -O exec/louper

- name: Build R source build
shell: bash
run: R CMD build .

- name: Rename source build
shell: bash
run: mv loupeR*tar.gz loupeR_${{ runner.os }}.tar.gz

- name: Upload build to release
run: gh release upload ${{ github.event.inputs.tag }} loupeR_${{ runner.os }}.tar.gz
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Rproj.user
.Rhistory
.Rdata
.httr-oauth
.DS_Store
22 changes: 22 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Package: loupeR
Title: Converts Seurat objects to 10x Genomics Loupe files
Version: 1.0.0
Authors@R:
person(given = "Eric",
family = "Siegel",
email = "eric.siegel@10xgenomics.com",
role = c("aut", "cre"))
Description: Converts Seurat objects to 10x Genomics Loupe files.
This is a second line to make the package checker not complain.
License: file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3.9000
Suggests:
testthat (>= 3.0.0),
Matrix
Config/testthat/edition: 3
Imports:
methods,
Seurat,
hdf5r
38 changes: 38 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Copyright (c) 2023 10x Genomics

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to use, copy, modify, and/or merge copies of the
Software, in both source code and object code format, solely for your internal use, subject to the
following conditions:

1. The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

2. The above rights granted in the Software may be exercised only in connection with a 10x Genomics
Product (defined below), rightfully purchased from 10x Genomics or an authorized reseller, or data
generated using such a 10x Genomics Product. A “10X Genomics Product” means, collectively, 10x
Genomics branded instruments, reagents, consumables, kits, and labware used in accordance with the
10X Genomics Product Terms and Conditions of Sale or, if applicable, any written contract between
you and 10x Genomics. The rights granted may also be exercised in connection with other products
when doing so is an integral part of an experiment where the data is generated primarily using a 10x
Genomics Product.

3. You agree not to redistribute or sublicense the Software, either in source code or object code
format.

4. All derivative works, including any modifications of the Software, shall be subject to all of the
restrictions set forth herein.

5. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE,
THE USE OR INABILITY TO USE, OR OTHER DEALINGS IN THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED
OF THE POSSIBILITY OF SUCH DAMAGES.

You may not use, propagate or modify the Software, or any derivatives thereof, except as expressly
provided herein. Any attempt otherwise to use, propagate or modify it is void, and will
automatically terminate your rights under this license.
24 changes: 24 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by roxygen2: do not edit by hand

export(create_bugreport)
export(create_bugreport_from_seurat)
export(create_loupe)
export(create_loupe_from_seurat)
export(select_assay)
export(select_clusters)
export(select_projections)
export(setup)
export(validate_clusters)
export(validate_count_mat)
export(validate_projections)
importFrom(Seurat,Assays)
importFrom(Seurat,GetAssay)
importFrom(Seurat,Idents)
importFrom(Seurat,Reductions)
importFrom(hdf5r,H5File)
importFrom(hdf5r,H5T_STRING)
importFrom(methods,is)
importFrom(utils,download.file)
importFrom(utils,packageVersion)
importFrom(utils,sessionInfo)
importFrom(utils,strcapture)
64 changes: 64 additions & 0 deletions R/cmd.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#' Create a Loupe file by invoking the external Louper executable
#'
#' @param h5path path to the h5 interchange file.
#' @param output_dir optional directory where the Loupe file will be written
#' @param output_name optional name of the Loupe file with the extensions not included.
#' @param executable_path optional path to the louper executable.
#' @param force optional logical as to whether we should overwrite an already existing file
#'
#' @return TRUE on success, FALSE on error
#'
#' @noRd
louper_create_cloupe <- function(
h5path,
output_dir = NULL,
output_name = NULL,
executable_path = NULL,
force = FALSE
) {
# default loupe name to `converted.cloupe`
if (is.null(output_name)) {
output_name <- "converted"
}
if (is.null(output_dir)) {
loupe_path <- sprintf("%s.cloupe", file.path(output_name))
} else {
loupe_path <- sprintf("%s.cloupe", file.path(output_dir, output_name))
}

h5path <- normalizePath(path.expand(h5path))
loupe_path <- suppressWarnings(normalizePath(path.expand(loupe_path)))

input_flag <- sprintf("--input=%s", h5path)
output_flag <- sprintf("--output=%s", loupe_path)
args <- c("create", input_flag, output_flag)

if (file.exists(loupe_path) && !force) {
return(err("Loupe file already exists. Set `force = TRUE` to overwrite"))
}

if (force) {
args <- c(args, "--force")
}

if (is.null(executable_path)) {
executable_path <- find_executable()
if (is.null(executable_path)) {
return(err("Could not find a valid louper executable. Please run `setup()`."))
}
}

executable_path <- normalizePath(path.expand(executable_path))

if (!file.exists(executable_path)) {
return(err(sprintf("cannot find Louper executable at path: '%s'", executable_path)))
}

status <- system2(command=executable_path, args=args)

if (status == 0) {
return(SUCCESS)
} else {
return(err(sprintf("Louper executable failed: status code %d", status)))
}
}
Loading

0 comments on commit 75e4bc8

Please sign in to comment.