Skip to content

Commit 75e4bc8

Browse files
committed
loupeR version 1.0.0
0 parents  commit 75e4bc8

34 files changed

Lines changed: 2324 additions & 0 deletions

.github/workflows/check.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
name: R-CMD-check
8+
9+
jobs:
10+
R-CMD-check:
11+
runs-on: ${{ matrix.config.os }}
12+
13+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
config:
19+
- {os: macos-latest, r: 'release'}
20+
- {os: windows-latest, r: 'release'}
21+
- {os: ubuntu-latest, r: 'release'}
22+
23+
env:
24+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
25+
R_KEEP_PKG_SOURCE: yes
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- uses: r-lib/actions/setup-pandoc@v2
31+
32+
- uses: r-lib/actions/setup-r@v2
33+
with:
34+
r-version: ${{ matrix.config.r }}
35+
http-user-agent: ${{ matrix.config.http-user-agent }}
36+
use-public-rspm: true
37+
38+
- uses: r-lib/actions/setup-r-dependencies@v2
39+
with:
40+
extra-packages: any::rcmdcheck
41+
needs: check
42+
43+
- uses: r-lib/actions/check-r-package@v2
44+
with:
45+
upload-snapshots: false

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
on:
2+
workflow_dispatch:
3+
inputs:
4+
tag:
5+
description: 'Git Tag/Release that we are uploading to'
6+
required: true
7+
8+
name: release
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
R-CMD-check:
15+
runs-on: ${{ matrix.config.os }}
16+
17+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
18+
19+
strategy:
20+
matrix:
21+
config:
22+
- {os: macos-latest, r: 'release'}
23+
- {os: windows-latest, r: 'release'}
24+
- {os: ubuntu-latest, r: 'release'}
25+
26+
env:
27+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
28+
R_KEEP_PKG_SOURCE: yes
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
33+
- uses: r-lib/actions/setup-pandoc@v2
34+
35+
- uses: r-lib/actions/setup-r@v2
36+
with:
37+
r-version: ${{ matrix.config.r }}
38+
http-user-agent: ${{ matrix.config.http-user-agent }}
39+
use-public-rspm: true
40+
41+
- uses: r-lib/actions/setup-r-dependencies@v2
42+
with:
43+
extra-packages: any::rcmdcheck
44+
needs: check
45+
46+
- uses: r-lib/actions/check-r-package@v2
47+
with:
48+
upload-snapshots: false
49+
50+
- name: Configure gh for auth
51+
env:
52+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
53+
run: gh auth setup-git
54+
55+
- name: Create Exec directory
56+
shell: bash
57+
run: mkdir exec
58+
59+
# Copy Louper binaries to the `exec` directory
60+
- name: Copy Louper binary to Exec directory (Windows)
61+
if: ${{ contains(matrix.config.os, 'windows') }}
62+
env:
63+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
64+
run: gh release download ${{ github.event.inputs.tag }} -p 'louper-windows*' -O exec/louper.exe
65+
- name: Copy Louper binary to Exec directory (Linux)
66+
if: ${{ contains(matrix.config.os, 'ubuntu') }}
67+
env:
68+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
69+
run: gh release download ${{ github.event.inputs.tag }} -p 'louper-linux*' -O exec/louper
70+
- name: Copy Louper binary to Exec directory (MacOS)
71+
if: ${{ contains(matrix.config.os, 'macos') }}
72+
env:
73+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
74+
run: gh release download ${{ github.event.inputs.tag }} -p 'louper-macos*' -O exec/louper
75+
76+
- name: Build R source build
77+
shell: bash
78+
run: R CMD build .
79+
80+
- name: Rename source build
81+
shell: bash
82+
run: mv loupeR*tar.gz loupeR_${{ runner.os }}.tar.gz
83+
84+
- name: Upload build to release
85+
run: gh release upload ${{ github.event.inputs.tag }} loupeR_${{ runner.os }}.tar.gz
86+
env:
87+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.Rproj.user
2+
.Rhistory
3+
.Rdata
4+
.httr-oauth
5+
.DS_Store

DESCRIPTION

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Package: loupeR
2+
Title: Converts Seurat objects to 10x Genomics Loupe files
3+
Version: 1.0.0
4+
Authors@R:
5+
person(given = "Eric",
6+
family = "Siegel",
7+
email = "eric.siegel@10xgenomics.com",
8+
role = c("aut", "cre"))
9+
Description: Converts Seurat objects to 10x Genomics Loupe files.
10+
This is a second line to make the package checker not complain.
11+
License: file LICENSE
12+
Encoding: UTF-8
13+
Roxygen: list(markdown = TRUE)
14+
RoxygenNote: 7.2.3.9000
15+
Suggests:
16+
testthat (>= 3.0.0),
17+
Matrix
18+
Config/testthat/edition: 3
19+
Imports:
20+
methods,
21+
Seurat,
22+
hdf5r

LICENSE

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Copyright (c) 2023 10x Genomics
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4+
associated documentation files (the "Software"), to use, copy, modify, and/or merge copies of the
5+
Software, in both source code and object code format, solely for your internal use, subject to the
6+
following conditions:
7+
8+
1. The above copyright notice and this permission notice shall be included in all copies or
9+
substantial portions of the Software.
10+
11+
2. The above rights granted in the Software may be exercised only in connection with a 10x Genomics
12+
Product (defined below), rightfully purchased from 10x Genomics or an authorized reseller, or data
13+
generated using such a 10x Genomics Product. A “10X Genomics Product” means, collectively, 10x
14+
Genomics branded instruments, reagents, consumables, kits, and labware used in accordance with the
15+
10X Genomics Product Terms and Conditions of Sale or, if applicable, any written contract between
16+
you and 10x Genomics. The rights granted may also be exercised in connection with other products
17+
when doing so is an integral part of an experiment where the data is generated primarily using a 10x
18+
Genomics Product.
19+
20+
3. You agree not to redistribute or sublicense the Software, either in source code or object code
21+
format.
22+
23+
4. All derivative works, including any modifications of the Software, shall be subject to all of the
24+
restrictions set forth herein.
25+
26+
5. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
27+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
29+
OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER IN
30+
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE,
31+
THE USE OR INABILITY TO USE, OR OTHER DEALINGS IN THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF
32+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
33+
THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED
34+
OF THE POSSIBILITY OF SUCH DAMAGES.
35+
36+
You may not use, propagate or modify the Software, or any derivatives thereof, except as expressly
37+
provided herein. Any attempt otherwise to use, propagate or modify it is void, and will
38+
automatically terminate your rights under this license.

NAMESPACE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(create_bugreport)
4+
export(create_bugreport_from_seurat)
5+
export(create_loupe)
6+
export(create_loupe_from_seurat)
7+
export(select_assay)
8+
export(select_clusters)
9+
export(select_projections)
10+
export(setup)
11+
export(validate_clusters)
12+
export(validate_count_mat)
13+
export(validate_projections)
14+
importFrom(Seurat,Assays)
15+
importFrom(Seurat,GetAssay)
16+
importFrom(Seurat,Idents)
17+
importFrom(Seurat,Reductions)
18+
importFrom(hdf5r,H5File)
19+
importFrom(hdf5r,H5T_STRING)
20+
importFrom(methods,is)
21+
importFrom(utils,download.file)
22+
importFrom(utils,packageVersion)
23+
importFrom(utils,sessionInfo)
24+
importFrom(utils,strcapture)

R/cmd.R

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#' Create a Loupe file by invoking the external Louper executable
2+
#'
3+
#' @param h5path path to the h5 interchange file.
4+
#' @param output_dir optional directory where the Loupe file will be written
5+
#' @param output_name optional name of the Loupe file with the extensions not included.
6+
#' @param executable_path optional path to the louper executable.
7+
#' @param force optional logical as to whether we should overwrite an already existing file
8+
#'
9+
#' @return TRUE on success, FALSE on error
10+
#'
11+
#' @noRd
12+
louper_create_cloupe <- function(
13+
h5path,
14+
output_dir = NULL,
15+
output_name = NULL,
16+
executable_path = NULL,
17+
force = FALSE
18+
) {
19+
# default loupe name to `converted.cloupe`
20+
if (is.null(output_name)) {
21+
output_name <- "converted"
22+
}
23+
if (is.null(output_dir)) {
24+
loupe_path <- sprintf("%s.cloupe", file.path(output_name))
25+
} else {
26+
loupe_path <- sprintf("%s.cloupe", file.path(output_dir, output_name))
27+
}
28+
29+
h5path <- normalizePath(path.expand(h5path))
30+
loupe_path <- suppressWarnings(normalizePath(path.expand(loupe_path)))
31+
32+
input_flag <- sprintf("--input=%s", h5path)
33+
output_flag <- sprintf("--output=%s", loupe_path)
34+
args <- c("create", input_flag, output_flag)
35+
36+
if (file.exists(loupe_path) && !force) {
37+
return(err("Loupe file already exists. Set `force = TRUE` to overwrite"))
38+
}
39+
40+
if (force) {
41+
args <- c(args, "--force")
42+
}
43+
44+
if (is.null(executable_path)) {
45+
executable_path <- find_executable()
46+
if (is.null(executable_path)) {
47+
return(err("Could not find a valid louper executable. Please run `setup()`."))
48+
}
49+
}
50+
51+
executable_path <- normalizePath(path.expand(executable_path))
52+
53+
if (!file.exists(executable_path)) {
54+
return(err(sprintf("cannot find Louper executable at path: '%s'", executable_path)))
55+
}
56+
57+
status <- system2(command=executable_path, args=args)
58+
59+
if (status == 0) {
60+
return(SUCCESS)
61+
} else {
62+
return(err(sprintf("Louper executable failed: status code %d", status)))
63+
}
64+
}

0 commit comments

Comments
 (0)