@@ -473,7 +473,7 @@ createArrowFiles <- function(
473473
474474 .logDiffTime(" Continuing through after error ggplot for Fragment Size Distribution" , t1 = tstart , logFile = logFile )
475475 # print(x)
476- message(" \n " )
476+ if (getArchRVerbose()) message(" \n " )
477477
478478 })
479479 gc()
@@ -537,7 +537,7 @@ createArrowFiles <- function(
537537
538538 .logDiffTime(" Continuing through after error ggplot for TSS by Frags" , t1 = tstart , logFile = logFile )
539539 # message(x)
540- message(" \n " )
540+ if (getArchRVerbose()) message(" \n " )
541541
542542 })
543543
@@ -1119,7 +1119,7 @@ createArrowFiles <- function(
11191119 TRUE
11201120 }, error = function (x ){
11211121 tryCatch({
1122- message(" Attempting to index " , file ," as tabix.." )
1122+ if (getArchRVerbose()) message(" Attempting to index " , file ," as tabix.." )
11231123 indexTabix(file , format = " bed" )
11241124 TRUE
11251125 }, error = function (y ){
@@ -1138,7 +1138,7 @@ createArrowFiles <- function(
11381138 }
11391139 }, error = function (x ){
11401140 tryCatch({
1141- message(" Attempting to index " , file ," as bam..." )
1141+ if (getArchRVerbose()) message(" Attempting to index " , file ," as bam..." )
11421142 indexBam(file )
11431143 TRUE
11441144 }, error = function (y ){
@@ -1278,7 +1278,7 @@ createArrowFiles <- function(
12781278 o <- .suppressAll(h5createDataset(tmpFile , chrRGLengths , storage.mode = " integer" , dims = c(lengthRG , 1 ), level = 0 ))
12791279 o <- .suppressAll(h5createDataset(tmpFile , chrRGValues , storage.mode = " character" ,
12801280 dims = c(lengthRG , 1 ), level = 0 , size = max(nchar(RG @ values )) + 1 ))
1281- o <- h5write(obj = cbind(dt $ V2 ,dt $ V3 - dt $ V2 ), file = tmpFile , name = chrPos )
1281+ o <- h5write(obj = cbind(dt $ V2 ,dt $ V3 - dt $ V2 + 1 ), file = tmpFile , name = chrPos )
12821282 o <- h5write(obj = RG @ lengths , file = tmpFile , name = chrRGLengths )
12831283 o <- h5write(obj = RG @ values , file = tmpFile , name = chrRGValues )
12841284
@@ -1314,7 +1314,7 @@ createArrowFiles <- function(
13141314 o <- .suppressAll(h5createDataset(tmpChrFile , chrRGValues , storage.mode = " character" ,
13151315 dims = c(lengthRG , 1 ), level = 0 , size = max(nchar(RG @ values )) + 1 ))
13161316
1317- o <- h5write(obj = cbind(dt $ V2 ,dt $ V3 - dt $ V2 ), file = tmpChrFile , name = chrPos )
1317+ o <- h5write(obj = cbind(dt $ V2 ,dt $ V3 - dt $ V2 + 1 ), file = tmpChrFile , name = chrPos )
13181318 o <- h5write(obj = RG @ lengths , file = tmpChrFile , name = chrRGLengths )
13191319 o <- h5write(obj = RG @ values , file = tmpChrFile , name = chrRGValues )
13201320
@@ -1650,7 +1650,7 @@ createArrowFiles <- function(
16501650 o <- .suppressAll(h5createDataset(tmpFile , chrRGValues , storage.mode = " character" ,
16511651 dims = c(lengthRG , 1 ), level = 0 , size = max(nchar(RG @ values )) + 1 ))
16521652
1653- o <- h5write(obj = cbind(dt $ start ,dt $ end - dt $ start ), file = tmpFile , name = chrPos )
1653+ o <- h5write(obj = cbind(dt $ start , dt $ end - dt $ start + 1 ), file = tmpFile , name = chrPos )
16541654 o <- h5write(obj = RG @ lengths , file = tmpFile , name = chrRGLengths )
16551655 o <- h5write(obj = RG @ values , file = tmpFile , name = chrRGValues )
16561656
@@ -1686,7 +1686,7 @@ createArrowFiles <- function(
16861686 o <- .suppressAll(h5createDataset(tmpChrFile , chrRGValues , storage.mode = " character" ,
16871687 dims = c(lengthRG , 1 ), level = 0 , size = max(nchar(RG @ values )) + 1 ))
16881688
1689- o <- h5write(obj = cbind(dt $ start ,dt $ end - dt $ start ), file = tmpChrFile , name = chrPos )
1689+ o <- h5write(obj = cbind(dt $ start , dt $ end - dt $ start + 1 ), file = tmpChrFile , name = chrPos )
16901690 o <- h5write(obj = RG @ lengths , file = tmpChrFile , name = chrRGLengths )
16911691 o <- h5write(obj = RG @ values , file = tmpChrFile , name = chrRGValues )
16921692
@@ -1930,14 +1930,29 @@ createArrowFiles <- function(
19301930 chrPos <- paste0(" Fragments/" ,chr ," /Ranges" )
19311931 chrRGLengths <- paste0(" Fragments/" ,chr ," /RGLengths" )
19321932 chrRGValues <- paste0(" Fragments/" ,chr ," /RGValues" )
1933- o <- h5createGroup(outArrow , paste0(" Fragments/" ,chr ))
1934- o <- .suppressAll(h5createDataset(outArrow , chrPos , storage.mode = " integer" , dims = c(length(fragments ), 2 ), level = 0 ))
1935- o <- .suppressAll(h5createDataset(outArrow , chrRGLengths , storage.mode = " integer" , dims = c(lengthRG , 1 ), level = 0 ))
1936- o <- .suppressAll(h5createDataset(outArrow , chrRGValues , storage.mode = " character" , dims = c(lengthRG , 1 ), level = 0 ,
1937- size = max(nchar(mcols(fragments )$ RG @ values )) + 1 ))
1938- o <- h5write(obj = cbind(start(fragments ),width(fragments )), file = outArrow , name = chrPos )
1939- o <- h5write(obj = mcols(fragments )$ RG @ lengths , file = outArrow , name = chrRGLengths )
1940- o <- h5write(obj = mcols(fragments )$ RG @ values , file = outArrow , name = chrRGValues )
1933+
1934+ if (lengthRG == 0 ){
1935+
1936+ .logMessage(msg = paste0(prefix , " detected 0 Fragments in cells passing filtering threshold for " , chr ), logFile = logFile )
1937+
1938+ o <- h5createGroup(outArrow , paste0(" Fragments/" ,chr ))
1939+ o <- .suppressAll(h5createDataset(outArrow , chrPos , storage.mode = " integer" , dims = c(0 , 2 ), level = 0 ))
1940+ o <- .suppressAll(h5createDataset(outArrow , chrRGLengths , storage.mode = " integer" , dims = c(0 , 1 ), level = 0 ))
1941+ o <- .suppressAll(h5createDataset(outArrow , chrRGValues , storage.mode = " character" , dims = c(0 , 1 ), level = 0 ,
1942+ size = 10 ))
1943+
1944+ }else {
1945+
1946+ o <- h5createGroup(outArrow , paste0(" Fragments/" ,chr ))
1947+ o <- .suppressAll(h5createDataset(outArrow , chrPos , storage.mode = " integer" , dims = c(length(fragments ), 2 ), level = 0 ))
1948+ o <- .suppressAll(h5createDataset(outArrow , chrRGLengths , storage.mode = " integer" , dims = c(lengthRG , 1 ), level = 0 ))
1949+ o <- .suppressAll(h5createDataset(outArrow , chrRGValues , storage.mode = " character" , dims = c(lengthRG , 1 ), level = 0 ,
1950+ size = max(nchar(mcols(fragments )$ RG @ values )) + 1 ))
1951+
1952+ o <- h5write(obj = cbind(start(fragments ),width(fragments )), file = outArrow , name = chrPos )
1953+ o <- h5write(obj = mcols(fragments )$ RG @ lengths , file = outArrow , name = chrRGLengths )
1954+ o <- h5write(obj = mcols(fragments )$ RG @ values , file = outArrow , name = chrRGValues )
1955+ }
19411956
19421957 # Free Some Memory!
19431958 rm(fragments )
@@ -1995,15 +2010,26 @@ createArrowFiles <- function(
19952010 chrRGLengths <- paste0(chr , " ._.RGLengths" )
19962011 chrRGValues <- paste0(chr , " ._.RGValues" )
19972012
1998- # HDF5 Write
1999- o <- .suppressAll(h5createDataset(tmpChrFile , chrPos , storage.mode = " integer" , dims = c(length(fragments ), 2 ), level = 0 ))
2000- o <- .suppressAll(h5createDataset(tmpChrFile , chrRGLengths , storage.mode = " integer" , dims = c(lengthRG , 1 ), level = 0 ))
2001- o <- .suppressAll(h5createDataset(tmpChrFile , chrRGValues , storage.mode = " character" , dims = c(lengthRG , 1 ), level = 0 ,
2002- size = max(nchar(mcols(fragments )$ RG @ values )) + 1 ))
2003-
2004- o <- h5write(obj = cbind(start(fragments ),width(fragments )), file = tmpChrFile , name = chrPos )
2005- o <- h5write(obj = mcols(fragments )$ RG @ lengths , file = tmpChrFile , name = chrRGLengths )
2006- o <- h5write(obj = mcols(fragments )$ RG @ values , file = tmpChrFile , name = chrRGValues )
2013+ if (lengthRG == 0 ){
2014+
2015+ # HDF5 Write
2016+ o <- .suppressAll(h5createDataset(tmpChrFile , chrPos , storage.mode = " integer" , dims = c(0 , 2 ), level = 0 ))
2017+ o <- .suppressAll(h5createDataset(tmpChrFile , chrRGLengths , storage.mode = " integer" , dims = c(0 , 1 ), level = 0 ))
2018+ o <- .suppressAll(h5createDataset(tmpChrFile , chrRGValues , storage.mode = " character" , dims = c(0 , 1 ), level = 0 ,
2019+ size = 10 ))
2020+
2021+ }else {
2022+
2023+ # HDF5 Write
2024+ o <- .suppressAll(h5createDataset(tmpChrFile , chrPos , storage.mode = " integer" , dims = c(length(fragments ), 2 ), level = 0 ))
2025+ o <- .suppressAll(h5createDataset(tmpChrFile , chrRGLengths , storage.mode = " integer" , dims = c(lengthRG , 1 ), level = 0 ))
2026+ o <- .suppressAll(h5createDataset(tmpChrFile , chrRGValues , storage.mode = " character" , dims = c(lengthRG , 1 ), level = 0 ,
2027+ size = max(nchar(mcols(fragments )$ RG @ values )) + 1 ))
2028+
2029+ o <- h5write(obj = cbind(start(fragments ),width(fragments )), file = tmpChrFile , name = chrPos )
2030+ o <- h5write(obj = mcols(fragments )$ RG @ lengths , file = tmpChrFile , name = chrRGLengths )
2031+ o <- h5write(obj = mcols(fragments )$ RG @ values , file = tmpChrFile , name = chrRGValues )
2032+ }
20072033
20082034 # Free Some Memory!
20092035 rm(fragments )
0 commit comments