@@ -214,8 +214,6 @@ SAIGE.Region = function(mu,
214214 i = indexChunk + 1
215215 while (i < = nRegions ){
216216 # for(i in (indexChunk+1):nRegions){
217-
218-
219217 if (mth == numberRegionsInChunk ){
220218 if (i + groups_per_chunk > nRegions ){
221219 nregions_ro_read = nRegions - i + 1
@@ -279,8 +277,6 @@ SAIGE.Region = function(mu,
279277 # print("outList$VarMat 1 ")
280278 # print(outList$VarMat)
281279
282-
283-
284280 if (regionTestType == " BURDEN" & is_fastTest ){
285281 if (! is.null(outList $ iswriteOutput )){
286282 if (! (outList $ iswriteOutput )){
@@ -775,8 +771,24 @@ if(regionTestType != "BURDEN"){
775771}
776772
777773
778- # output
774+ if (is_output_markerList_in_groupTest ){
775+ rm(Output_MarkerList )
776+ }
777+
778+ rm(outList )
779+ rm(pval.Region )
780+ if (regionTestType != " BURDEN" ){
781+ rm(resultDF )
782+ }
783+ gc()
784+
785+ }# if(length(noNAIndices) > 0){
786+ }else {# if(!is.null(region)){
787+ cat(regionName , " is empty.\n " )
788+ }
789+
779790
791+ # output
780792if (mth == numberRegionsInChunk ){
781793 message1 = " This is the output index file for SAIGE package to record the end point in case users want to restart the analysis. Please do not modify this file."
782794 message2 = paste(" This is a" , AnalysisType , " level analysis." )
@@ -788,7 +800,7 @@ if(mth == numberRegionsInChunk){
788800 cat(" write to output\n " )
789801 # cat("n1 is ", n1, "\n")
790802 # cat("n2 is ", n2, "\n")
791- if (regionTestType != " BURDEN" ){
803+ if (regionTestType != " BURDEN" ){
792804 if (Start ){
793805 if (! is.null(pval.Region.all )){
794806 fwrite(pval.Region.all , OutputFile , quote = F , sep = " \t " , append = F , col.names = T , row.names = F , na = " NA" )
@@ -800,7 +812,7 @@ if(mth == numberRegionsInChunk){
800812 # write.table(Output, OutputFile, quote = F, sep = "\t", append = T, col.names = F, row.names = F)
801813 }
802814 }
803- if (is_output_markerList_in_groupTest ){
815+ if (is_output_markerList_in_groupTest ){
804816 if (Start ){
805817 if (! is.null(Output_MarkerList.all )){
806818 fwrite(Output_MarkerList.all , paste0(OutputFile , " .markerList.txt" ), quote = F , sep = " \t " , append = F , col.names = T , row.names = F , na = " NA" )
@@ -835,32 +847,8 @@ cth_chunk_to_output = cth_chunk_to_output + 1
835847gc()
836848}
837849
838- # tp2 = proc.time()
839- # print("tp2 - tp1")
840- # print(tp2 - tp1)
841- # print("tp2 - ta2")
842- # print(tp2 - ta2)
843- # if(is_single_in_groupTest){
844- # rm(OutList)
845- # }
846-
847- if (is_output_markerList_in_groupTest ){
848- rm(Output_MarkerList )
849- }
850-
851- rm(outList )
852- rm(pval.Region )
853- if (regionTestType != " BURDEN" ){
854- rm(resultDF )
855- }
856- gc()
857-
858- }# if(length(noNAIndices) > 0){
859- }else {# if(!is.null(region)){
860- cat(regionName , " is empty.\n " )
861- }
862850
863- }else {# if(!is.null(RegionList)){
851+ }else {# if(!is.null(RegionList)){
864852 cat(" The chunk is empty\n " )
865853 # mth = 0
866854 mth = numberRegionsInChunk
0 commit comments