Skip to content

Commit

Permalink
intial archr commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jgranja24 committed Oct 18, 2019
1 parent 3e93a9e commit 38b024e
Show file tree
Hide file tree
Showing 134 changed files with 14,245 additions and 1 deletion.
17 changes: 17 additions & 0 deletions ArchR.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
39 changes: 39 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Package: ArchR
Type: Package
Date: 2019-10-17
Title: Analyzing regulatory chromatin in R
Version: 0.1.4
Author: Jeffrey Granja [aut, cre], Ryan Corces [aut]
Maintainer: Jeffrey Granja <[email protected]>
Description: This package is designed to streamline scATAC analyses in R.
License: GPL (>= 2)
LinkingTo: Rcpp
LazyData: TRUE
RoxygenNote: 6.1.1
Encoding: UTF-8
Imports:
Rcpp (>= 0.12.16),
matrixStats,
plyr,
SummarizedExperiment,
Matrix,
nabor,
motifmatchr,
chromVAR,
uwot,
ggrepel,
Rsamtools,
gtable,
grid,
gridExtra,
Biostrings,
ComplexHeatmap,
Depends:
ggplot2,
data.table,
rhdf5,
magrittr,
S4Vectors (>= 0.9.25),
BiocGenerics,
GenomicRanges,

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 jgranja24

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

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

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, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
135 changes: 135 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Generated by roxygen2: do not edit by hand

export("%bcin%")
export("%bcni%")
export("%ni%")
export(.ArchRLogo)
export(.addMatToArrow)
export(.availableCells)
export(.availableChr)
export(.availableSeqnames)
export(.batchlapply)
export(.centerRollMean)
export(.checkPath)
export(.computeROC)
export(.confusionMatrix)
export(.fileExtension)
export(.fixPlotSize)
export(.getAssay)
export(.getColSums)
export(.getFeatureDF)
export(.getFragsFromArrow)
export(.getGroupMatrix)
export(.getMatFromArrow)
export(.getMatrixValues)
export(.getMetadata)
export(.getPartialMatrix)
export(.getQuantiles)
export(.getRowSums)
export(.groupMeans)
export(.groupSds)
export(.groupSums)
export(.h5read)
export(.initializeMat)
export(.isProtectedArray)
export(.mergeParams)
export(.messageDiffTime)
export(.normalizeCols)
export(.nullGeneAnnotation)
export(.nullGenomeAnnotation)
export(.quantileCut)
export(.requirePackage)
export(.rowScale)
export(.rowZscores)
export(.safeSubset)
export(.safelapply)
export(.sampleName)
export(.summarizeArrowContent)
export(.suppressAll)
export(.validArrow)
export(.validBSgenome)
export(.validGRanges)
export(.validOrgDb)
export(.validTxDb)
export(ArchRProject)
export(ArchRRegionTrack)
export(ArchR_palettes)
export(ComputeEmbedding)
export(FilterCells)
export(IdentifyClusters)
export(IterativeLSI)
export(VisualizeEmbedding)
export(VisualizeGroups)
export(addBackgroundPeaks)
export(addCellColData)
export(addDemuxletResults)
export(addDeviationsMatrix)
export(addDoubletScores)
export(addFeatureMatrix)
export(addGeneScoreMatrix)
export(addGroupCoverages)
export(addMotifAnnotations)
export(addPeakMatrix)
export(addPeakSet)
export(addReproduciblePeakSet)
export(addSampleColData)
export(addSeqLengths)
export(addTileMatrix)
export(alignCellsToTrajectory)
export(availableFeatures)
export(columnOverlaps)
export(computeCoAccessibility)
export(computeKNN)
export(computeLSI)
export(constructGRanges)
export(createArrowFiles)
export(extendGRanges)
export(featureEnrichment)
export(getAnnotation)
export(getArrowFiles)
export(getBlacklist)
export(getCellColData)
export(getCellNames)
export(getChromLengths)
export(getChromSizes)
export(getEmbedding)
export(getExons)
export(getFragmentsFromArrow)
export(getGeneAnnotation)
export(getGenes)
export(getGenome)
export(getGenomeAnnotation)
export(getMatches)
export(getMatrixFromArrow)
export(getOutputDirectory)
export(getPeakSet)
export(getPositions)
export(getReducedDims)
export(getSampleColData)
export(getSampleNames)
export(getTSS)
export(ggAlignPlots)
export(ggHex)
export(ggLine)
export(ggOneToOne)
export(ggPoint)
export(ggViolin)
export(keepFilteredChromosomes)
export(markerFeatures)
export(markerHeatmap)
export(mergeGRanges)
export(nonOverlappingGRanges)
export(overlappingBP)
export(overlapsMany)
export(paletteContinuous)
export(paletteDiscrete)
export(plotFootprint)
export(plotPDF)
export(plotPeakCallSummary)
export(projectLSI)
export(shuffleGRanges)
export(subsetSeqnames)
export(summarizeFootprints)
export(theme_ArchR)
importFrom(Rcpp,sourceCpp)
useDynLib(ArchR)
Binary file added R/.DS_Store
Binary file not shown.
Empty file added R/.Rapp.history
Empty file.
110 changes: 110 additions & 0 deletions R/AllClasses.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#' @useDynLib ArchR
#' @importFrom Rcpp sourceCpp
NULL

setClassUnion("characterOrNull", c("character", "NULL"))
setClassUnion("GRangesOrNull", c("GRanges", "NULL"))

setClass("ArchRProject",
representation(
projectMetadata = "SimpleList",
sampleColData = "DataFrame",
sampleMetadata = "SimpleList",
cellColData = "DataFrame",
cellMetadata = "SimpleList", #Where clustering output will go to
reducedDims = "SimpleList", #Where clustering output will go to
embeddings = "SimpleList", #Where clustering output will go to
peakSet = "GRangesOrNull",
annotations = "SimpleList", #MotifMatches ETC go here
geneAnnotation = "SimpleList", #genes exons TSS
genomeAnnotation = "SimpleList" #genome chromSizes BSgenome blacklist
)
)

setMethod("show", "ArchRProject",
function(object) {
scat <- function(fmt, vals=character(), exdent=2, n = 5, ...){
vals <- ifelse(nzchar(vals), vals, "''")
lbls <- paste(S4Vectors:::selectSome(vals, maxToShow = n), collapse=" ")
txt <- sprintf(fmt, length(vals), lbls)
cat(strwrap(txt, exdent=exdent, ...), sep="\n")
}
.ArchRLogo(ascii = "Package")
cat("class:", class(object), "\n")
cat("outputDirectory:", object@projectMetadata$outputDirectory, "\n")
scat("samples(%d): %s\n", rownames(object@sampleColData))
scat("sampleColData names(%d): %s\n", names(object@sampleColData))
scat("cellColData names(%d): %s\n", names(object@cellColData))
scat("numberOfCells(%d): %s\n", nrow(object@cellColData))
scat("medianTSS(%d): %s\n", median(object@cellColData$TSSEnrichment))
scat("medianFrags(%d): %s\n", median(object@cellColData$nFrags))
}
)

#' @export
ArchRProject <- function(
ArrowFiles=NULL,
sampleNames=NULL,
outputDirectory = "ArchR_Results",
copyArrows = FALSE,
geneAnnotation = NULL,
genomeAnnotation = NULL,
showLogo = TRUE){

if(is.null(ArrowFiles)){
stop("Need to Provide Arrow Files!")
}

#Validate
message("Validating Arrows...")
ArrowFiles <- unlist(lapply(ArrowFiles, .validArrow))

if(is.null(sampleNames)){
message("Getting SampleNames...")
sampleNames <- unlist(lapply(seq_along(ArrowFiles), function(x) .sampleName(ArrowFiles[x])))
}

if(any(duplicated(sampleNames))){
stop("Error cannot have duplicate sampleNames, please add sampleNames that will overwrite the current sample name in Arrow file!")
}

if(length(sampleNames) != length(ArrowFiles)) stop("Samples is not equal to input ArrowFiles!")

dir.create(outputDirectory,showWarnings=FALSE)
sampleDirectory <- file.path(normalizePath(outputDirectory),"InputArrows")
dir.create(sampleDirectory,showWarnings=FALSE)

if(copyArrows){
message("Copying ArrowFiles to Ouptut Directory!")
cf <- file.copy(ArrowFiles, file.path(sampleDirectory, paste0(sampleNames, ".arrow")))
ArrowFiles <- file.path(sampleDirectory, paste0(sampleNames, ".arrow"))
}

#Sample Information
sampleColData <- DataFrame(row.names = sampleNames, ArrowFiles = ArrowFiles)
sampleMetadata <- SimpleList(lapply(sampleNames, function(x) SimpleList()))
names(sampleMetadata) <- sampleNames

#Cell Information
metadataList <- lapply(ArrowFiles, .getMetadata)
intCols <- Reduce("intersect",lapply(metadataList,colnames))
cellColData <- lapply(metadataList, function(x) x[,intCols]) %>% Reduce("rbind",.)

proj <- new("ArchRProject",
projectMetadata = SimpleList(outputDirectory = normalizePath(outputDirectory)),
sampleColData = sampleColData,
sampleMetadata = sampleMetadata,
cellColData = cellColData,
cellMetadata = SimpleList(),
reducedDims = SimpleList(),
embeddings = SimpleList(),
annotations = SimpleList(),
geneAnnotation = geneAnnotation,
genomeAnnotation = genomeAnnotation)
if(showLogo){
.ArchRLogo(ascii = "Logo")
}
proj

}

Loading

0 comments on commit 38b024e

Please sign in to comment.