Skip to content

Commit

Permalink
initial file stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jlanej committed Mar 29, 2024
1 parent 35061e8 commit c23d96e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# History files
.Rhistory
.Rapp.history

*.Rproj
# Session Data files
.RData
.RDataTmp
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
FROM r-base

RUN R -e "install.packages('optparse',dependencies=TRUE, repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('Rsamtools',dependencies=TRUE, repos='http://cran.rstudio.com/')"
ENV BASE=/app/

WORKDIR ${BASE}
COPY ./ ${BASE}
CMD ["Rscript", "longReadPlot.R"]

29 changes: 29 additions & 0 deletions bamRUtils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require(Rsamtools)


.unlist <- function (x)
{
## do.call(c, ...) coerces factor to integer, which is undesired
x1 <- x[[1L]]
if (is.factor(x1)) {
structure(unlist(x), class = "factor", levels = levels(x1))
} else {
do.call(c, x)
}
}

convertBam <- function(bam, param) {
bam <- unname(bam) # names not useful in unlisted result
elts <- setNames(bamWhat(param), bamWhat(param))
lst <- lapply(elts, function(elt)
.unlist(lapply(bam, "[[", elt)))
lst = lst[lengths(lst) != 0]
df <- do.call("data.frame", bam)
return(df)
}

loadBam <- function(bamFile, param) {
bam = scanBam(bamFile, param = param)
bam = convertBam(bam = bam, param = param)
return(bam)
}
3 changes: 3 additions & 0 deletions longReadPlot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library(optparse)
source("bamRUtils.R")
print("hi")

0 comments on commit c23d96e

Please sign in to comment.