Skip to content

Commit

Permalink
0.9.2 (#83)
Browse files Browse the repository at this point in the history
* bugfix rowData names

* bugfix early exit of loopTracks if return is in trycatch and adding checks for ggplot at the end of plot.

also reset resolution to 1

* update 0.9.2
  • Loading branch information
jgranja24 committed Apr 28, 2020
1 parent 767bf84 commit c323e3c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: ArchR
Type: Package
Date: 2019-03-10
Title: Analyzing single-cell regulatory chromatin in R.
Version: 0.9.1
Version: 0.9.2
Authors@R: c(
person("Jeffrey", "Granja", email = "jgranja.stanford@gmail.com", role = c("aut","cre")),
person("Ryan", "Corces", role = "aut"))
Expand Down
38 changes: 30 additions & 8 deletions R/ArchRBrowser.R
Original file line number Diff line number Diff line change
Expand Up @@ -822,15 +822,21 @@ plotBrowserTrack <- function(
# Time to plot
##########################################################
plotSummary <- tolower(plotSummary)
names(sizes) <- plotSummary
sizes <- sizes[order(plotSummary)]
plotSummary <- plotSummary[order(plotSummary)]

nullSummary <- unlist(lapply(seq_along(plotSummary), function(x) is.null(eval(parse(text=paste0("plotList$", plotSummary[x]))))))
if(any(nullSummary)){
sizes <- sizes[-which(nullSummary)]
}
# nullSummary <- unlist(lapply(seq_along(plotSummary), function(x) is.null(eval(parse(text=paste0("plotList$", plotSummary[x]))))))
# if(any(nullSummary)){
# sizes <- sizes[-which(nullSummary)]
# }
sizes <- sizes[tolower(names(plotList))]

.logThis(names(plotList), sprintf("(%s of %s) names(plotList)",x,length(region)), logFile=logFile)
.logThis(sizes, sprintf("(%s of %s) sizes",x,length(region)), logFile=logFile)
#.logThis(nullSummary, sprintf("(%s of %s) nullSummary",x,length(region)), logFile=logFile)
.logDiffTime("Plotting", t1=tstart, verbose=verbose, logFile=logFile)

tryCatch({
suppressWarnings(ggAlignPlots(plotList = plotList, sizes=sizes, draw = FALSE))
}, error = function(e){
Expand Down Expand Up @@ -1292,6 +1298,10 @@ plotBrowserTrack <- function(

}

if(!is.ggplot(p)){
.logError("geneTrack is not a ggplot!", fn = ".geneTracks", info = "", errorList = NULL, logFile = logFile)
}

return(p)

}
Expand Down Expand Up @@ -1379,7 +1389,6 @@ plotBrowserTrack <- function(

}


if(hideX){
p <- p + theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank())
}
Expand All @@ -1388,6 +1397,10 @@ plotBrowserTrack <- function(
p <- p + theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank())
}

if(!is.ggplot(p)){
.logError("featureTrack is not a ggplot!", fn = ".featureTracks", info = "", errorList = NULL, logFile = logFile)
}

return(p)

}
Expand Down Expand Up @@ -1450,22 +1463,24 @@ plotBrowserTrack <- function(

testDim <- tryCatch({
if(is.null(loopO)){
return(FALSE)
FALSE
}
if(nrow(loopO) > 0){
return(TRUE)
TRUE
}else{
return(FALSE)
FALSE
}
}, error = function(x){
FALSE
})

if(testDim){

loopO$facet <- title
if(is.null(pal)){
pal <- colorRampPalette(c("#E6E7E8","#3A97FF","#8816A7","black"))(100)
}

p <- ggplot(data = data.frame(loopO), aes(x = x, y = y, group = id, color = value)) +
geom_line() +
facet_grid(name ~ .) +
Expand All @@ -1478,7 +1493,9 @@ plotBrowserTrack <- function(
theme(strip.text.y = element_text(size = facetbaseSize, angle = 0), strip.background = element_blank(),
legend.box.background = element_rect(color = NA)) +
guides(color= guide_colorbar(barwidth = 0.75, barheight = 3))

}else{

#create empty plot
df <- data.frame(facet = "LoopTrack", start = 0, end = 0, strand = "*", symbol = "none")
p <- ggplot(data = df, aes(start, end)) +
Expand All @@ -1488,6 +1505,7 @@ plotBrowserTrack <- function(
scale_x_continuous(limits = c(start(region), end(region)), expand = c(0,0)) +
theme(axis.title.x=element_blank(), axis.text.x=element_blank(),axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(), axis.text.y=element_blank(),axis.ticks.y=element_blank())

}

}else{
Expand All @@ -1512,6 +1530,10 @@ plotBrowserTrack <- function(
p <- p + theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank())
}

if(!is.ggplot(p)){
.logError("loopTracks is not a ggplot!", fn = ".loopTracks", info = "", errorList = NULL, logFile = logFile)
}

return(p)

}
Expand Down
14 changes: 12 additions & 2 deletions R/IntegrativeAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ addCoAccessibility <- function(
getCoAccessibility <- function(
ArchRProj = NULL,
corCutOff = 0.5,
resolution = 1000,
resolution = 1,
returnLoops = TRUE
){

Expand Down Expand Up @@ -1003,10 +1003,12 @@ addPeak2GeneLinks <- function(

#Get Peak Set
peakSet <- getPeakSet(ArchRProj)
.logThis(peakSet, "peakSet", logFile = logFile)

#Gene Info
geneSet <- .getFeatureDF(ArrowFiles, useMatrix, threads = threads)
geneStart <- GRanges(geneSet$seqnames, IRanges(geneSet$start, width = 1), name = geneSet$name, idx = geneSet$idx)
.logThis(geneStart, "geneStart", logFile = logFile)

#Get Reduced Dims
rD <- getReducedDims(ArchRProj, reducedDims = reducedDims, corCutOff = corCutOff, dimsToUse = dimsToUse)
Expand Down Expand Up @@ -1052,6 +1054,7 @@ addPeak2GeneLinks <- function(
threads = threads,
verbose = FALSE
)
.logThis(groupMatRNA, "groupMatRNA", logFile = logFile)

#Group Matrix ATAC
.logDiffTime(main="Getting Group ATAC Matrix", t1=tstart, verbose=verbose, logFile=logFile)
Expand All @@ -1063,6 +1066,7 @@ addPeak2GeneLinks <- function(
threads = threads,
verbose = FALSE
)
.logThis(groupMatATAC, "groupMatATAC", logFile = logFile)

.logDiffTime(main="Normalizing Group Matrices", t1=tstart, verbose=verbose, logFile=logFile)

Expand All @@ -1074,17 +1078,23 @@ addPeak2GeneLinks <- function(
groupMatATAC <- log2(groupMatATAC + 1)
}

names(geneStart) <- NULL

seRNA <- SummarizedExperiment(
assays = SimpleList(RNA = groupMatRNA),
rowRanges = geneStart
)
metadata(seRNA)$KNNList <- knnObj
.logThis(seRNA, "seRNA", logFile = logFile)

names(peakSet) <- NULL

seATAC <- SummarizedExperiment(
assays = SimpleList(ATAC = groupMatATAC),
rowRanges = peakSet
)
metadata(seATAC)$KNNList <- knnObj
.logThis(seATAC, "seATAC", logFile = logFile)

rm(groupMatRNA, groupMatATAC)
gc()
Expand Down Expand Up @@ -1204,7 +1214,7 @@ getPeak2GeneLinks <- function(
ArchRProj = NULL,
corCutOff = 0.45,
FDRCutOff = 0.0001,
resolution = 1000,
resolution = 1,
returnLoops = TRUE
){

Expand Down

0 comments on commit c323e3c

Please sign in to comment.