Introduction

Get human, chimp, and rhesus autosomal tDMRs

# Chimp heart-liver

# columns to pull
pull_col <- c(1:3, 16)

# make bed style format
humans_heart_liver_DMRs_bed <- chimps_heart_liver_DMRs[,pull_col]

# Get DMRs on the autosomal chromosomes only
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed[which(humans_heart_liver_DMRs_bed[,1] != "chrX"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

summary(humans_heart_liver_DMRs_bed_noX[,3] - humans_heart_liver_DMRs_bed_noX[,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     5.0   266.0   498.0   617.6   849.0  4950.0
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr11_gl000202_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr17_gl000204_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

sort_chimps_heart_liver_DMRs_bed <- bedr.sort.region(humans_heart_liver_DMRs_bed_noX)
## SORTING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Overlapping regions can cause unexpected results.
# Chimp heart-lung

# columns to pull
pull_col <- c(1:3, 16)

# make bed style format
humans_heart_liver_DMRs_bed <- chimps_heart_lung_DMRs[,pull_col]

# Get DMRs on the autosomal chromosomes only
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed[which(humans_heart_liver_DMRs_bed[,1] != "chrX"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr11_gl000202_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr17_gl000204_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

sort_chimps_heart_lung_DMRs_bed <- bedr.sort.region(humans_heart_liver_DMRs_bed_noX)
## SORTING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Overlapping regions can cause unexpected results.
# chimp heart-kidney

# columns to pull
pull_col <- c(1:3, 16)

# make bed style format
humans_heart_liver_DMRs_bed <- chimps_heart_kidney_DMRs[,pull_col]

# Get DMRs on the autosomal chromosomes only
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed[which(humans_heart_liver_DMRs_bed[,1] != "chrX"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr11_gl000202_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr17_gl000204_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

summary(humans_heart_liver_DMRs_bed_noX[,3] - humans_heart_liver_DMRs_bed_noX[,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     4.0   247.0   463.0   565.2   788.0  4173.0
sort_chimps_heart_kidney_DMRs_bed <- bedr.sort.region(humans_heart_liver_DMRs_bed_noX, check.chr = FALSE)
## SORTING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Overlapping regions can cause unexpected results.
# Chimp liver-lung

# columns to pull
pull_col <- c(1:3, 16)

# make bed style format
humans_heart_liver_DMRs_bed <- chimps_liver_lung_DMRs[,pull_col]

# Get DMRs on the autosomal chromosomes only
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed[which(humans_heart_liver_DMRs_bed[,1] != "chrX"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

summary(humans_heart_liver_DMRs_bed_noX[,3] - humans_heart_liver_DMRs_bed_noX[,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     5.0   247.0   459.0   577.9   793.0  5105.0
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr11_gl000202_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr17_gl000204_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

sort_chimps_liver_lung_DMRs_bed <- bedr.sort.region(humans_heart_liver_DMRs_bed_noX)
## SORTING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Overlapping regions can cause unexpected results.
# chimp liver-kidney

# columns to pull
pull_col <- c(1:3, 16)

# make bed style format
humans_heart_liver_DMRs_bed <- chimps_liver_kidney_DMRs[,pull_col]

# Get DMRs on the autosomal chromosomes only
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed[which(humans_heart_liver_DMRs_bed[,1] != "chrX"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

summary(humans_heart_liver_DMRs_bed_noX[,3] - humans_heart_liver_DMRs_bed_noX[,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       4     245     464     571     785    4733
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr11_gl000202_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr17_gl000204_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

sort_chimps_liver_kidney_DMRs_bed <- bedr.sort.region(humans_heart_liver_DMRs_bed_noX)
## SORTING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Overlapping regions can cause unexpected results.
# chimp lung-kidney

# columns to pull
pull_col <- c(1:3, 16)

# make bed style format
humans_heart_liver_DMRs_bed <- chimps_lung_kidney_DMRs[,pull_col]

# Get DMRs on the autosomal chromosomes only
humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed[which(humans_heart_liver_DMRs_bed[,1] != "chrX"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr11_gl000202_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])

humans_heart_liver_DMRs_bed_noX <- humans_heart_liver_DMRs_bed_noX[which(humans_heart_liver_DMRs_bed_noX[,1] != "chr17_gl000204_random"),]

humans_heart_liver_DMRs_bed_noX[,1] <- as.character(humans_heart_liver_DMRs_bed_noX[,1])
humans_heart_liver_DMRs_bed_noX[,2] <- as.integer(humans_heart_liver_DMRs_bed_noX[,2])
humans_heart_liver_DMRs_bed_noX[,3] <- as.integer(humans_heart_liver_DMRs_bed_noX[,3])
summary(humans_heart_liver_DMRs_bed_noX[,3] - humans_heart_liver_DMRs_bed_noX[,2])
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     4.0   230.0   430.0   523.8   727.2  3703.0
sort_chimps_lung_kidney_DMRs_bed <- bedr.sort.region(humans_heart_liver_DMRs_bed_noX)
## SORTING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Overlapping regions can cause unexpected results.

Number of autosomal tDMRs

# Humans
nrow(sort_humans_heart_liver_DMRs_bed)
## [1] 22561
nrow(sort_humans_heart_lung_DMRs_bed)
## [1] 14208
nrow(sort_humans_heart_kidney_DMRs_bed)
## [1] 30291
nrow(sort_humans_liver_lung_DMRs_bed)
## [1] 12842
nrow(sort_humans_liver_kidney_DMRs_bed)
## [1] 17910
nrow(sort_humans_lung_kidney_DMRs_bed)
## [1] 16521
summary(sort_humans_heart_liver_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   11695   10866
summary(sort_humans_heart_lung_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    9488    4720
summary(sort_humans_heart_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   12852   17439
summary(sort_humans_liver_lung_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    8090    4752
summary(sort_humans_liver_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    6368   11542
summary(sort_humans_lung_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    4421   12100
# Chimps
nrow(sort_chimps_heart_liver_DMRs_bed)
## [1] 28767
nrow(sort_chimps_heart_lung_DMRs_bed)
## [1] 8524
nrow(sort_chimps_heart_kidney_DMRs_bed)
## [1] 17699
nrow(sort_chimps_liver_lung_DMRs_bed)
## [1] 22107
nrow(sort_chimps_liver_kidney_DMRs_bed)
## [1] 23847
nrow(sort_chimps_lung_kidney_DMRs_bed)
## [1] 12076
summary(sort_chimps_heart_liver_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   13564   15203
summary(sort_chimps_heart_lung_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    5387    3137
summary(sort_chimps_heart_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    7978    9721
summary(sort_chimps_liver_lung_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   14317    7790
summary(sort_chimps_liver_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   11708   12139
summary(sort_chimps_lung_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    3900    8176
# Rhesus
nrow(sort_rhesus_heart_liver_DMRs_bed)
## [1] 41280
nrow(sort_rhesus_heart_lung_DMRs_bed)
## [1] 7026
nrow(sort_rhesus_heart_kidney_DMRs_bed)
## [1] 23023
nrow(sort_rhesus_liver_lung_DMRs_bed)
## [1] 32636
nrow(sort_rhesus_liver_kidney_DMRs_bed)
## [1] 35910
nrow(sort_rhesus_lung_kidney_DMRs_bed)
## [1] 15889
summary(sort_rhesus_heart_liver_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   18796   22484
summary(sort_rhesus_heart_lung_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    4068    2958
summary(sort_rhesus_heart_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    9784   13239
summary(sort_rhesus_liver_lung_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   19475   13161
summary(sort_rhesus_liver_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical   18493   17417
summary(sort_rhesus_lung_kidney_DMRs_bed$direction == "hyper")
##    Mode   FALSE    TRUE 
## logical    5611   10278

Identify human-specific versus conserved DMRs

The goal of this is to look for human specific versus conserved in 1 pair of tissues when you define conservation as overlap at a variety of bp overlaps.

Run for all tissues

1% overlap- all

# Heart-kidney

tissue_conserved_1_overlap(sort_humans_heart_kidney_DMRs_bed, sort_chimps_heart_kidney_DMRs_bed, sort_rhesus_heart_kidney_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8170df50b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a847c0a731.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85ce11841.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a873be5486.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85e8364.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83d27f9ee.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a876418f4a.bed -d 0 -c 4 -o collapse
##  * Collapsing 8621 --> 8412 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82598c6a3.bed -d 0 -c 4 -o collapse
##  * Collapsing 6486 --> 6223 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84307f303.bed -d 0 -c 4 -o collapse
##  * Collapsing 4953 --> 4785 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a832ce27af.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a837e5bc72.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85c13d7e6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83cdd8c98.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a820e7cd3a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82fb2ffec.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8486c3150.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8bc09e47.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82e403225.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83180e135.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]          18751           7585           15098 5269 3080 1654
##      hcr_conserved
## [1,]          3191
#      human_specific chimp_specific rhesus_specific   hc   hr cr
#[1,]          18751           7585           15098 5269 3080 1654
#     hcr_conserved
#[1,]          3191

# Heart liver
tissue_conserved_1_overlap(sort_humans_heart_liver_DMRs_bed, sort_chimps_heart_liver_DMRs_bed, sort_rhesus_heart_liver_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8fd933f0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8a8beb53.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a853035021.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87df5b2e7.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83bc5df5a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8334af86a.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8153717cd.bed -d 0 -c 4 -o collapse
##  * Collapsing 11211 --> 10883 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82c6a3ed7.bed -d 0 -c 4 -o collapse
##  * Collapsing 8914 --> 8449 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85fd37c56.bed -d 0 -c 4 -o collapse
##  * Collapsing 11097 --> 10466 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83bb04be9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85c19c416.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a812e77aec.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a879ca7eb5.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81930a66d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87501f0c8.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a873ccd4e5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82edd1d01.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a880a5702.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83bba6397.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           8652          12855           27802 5310 2876 4879
##      hcr_conserved
## [1,]          5723
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           8652          12855           27802 5310 2876 4879
#     hcr_conserved
#[1,]          5723
     
     
# Heart lung
tissue_conserved_1_overlap(sort_humans_heart_lung_DMRs_bed, sort_chimps_heart_lung_DMRs_bed, sort_rhesus_heart_lung_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a859fa5ed2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8490a5c94.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a844f87e55.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84e648934.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84ecf2193.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a853c3a957.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8394ec7c3.bed -d 0 -c 4 -o collapse
##  * Collapsing 3038 --> 2987 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8f7ffa5.bed -d 0 -c 4 -o collapse
##  * Collapsing 1491 --> 1456 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81d71ab5b.bed -d 0 -c 4 -o collapse
##  * Collapsing 1330 --> 1293 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a88c7e4ed.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84b4dce3b.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86096dd9c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a870466990.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a845622684.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87edc82cb.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82fc3aebe.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a844301460.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85e97ad79.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84017d642.bed -wao
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]          10440           4927            4960 2294 763 592
##      hcr_conserved
## [1,]           711
#     human_specific chimp_specific rhesus_specific   hc  hr  cr
#[1,]          10440           4927            4960 2294 763 592
#     hcr_conserved
#[1,]           711

# Liver lung
tissue_conserved_1_overlap(sort_humans_liver_lung_DMRs_bed, sort_chimps_liver_lung_DMRs_bed, sort_rhesus_liver_lung_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a871c4cf44.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82aa83d19.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85ec2fa25.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84b641bb1.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8ef4a8bc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a838724be4.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a840cfdc35.bed -d 0 -c 4 -o collapse
##  * Collapsing 6790 --> 6595 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8866c4c8.bed -d 0 -c 4 -o collapse
##  * Collapsing 5201 --> 4945 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8319f7890.bed -d 0 -c 4 -o collapse
##  * Collapsing 7738 --> 7298 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a899cc17d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82f7e5b2a.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8364469c2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a879bb2bda.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a865efb2a8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a877555cbe.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a867a887cc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87a3f50b1.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a814c83a28.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8471829d9.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           4476          11393           23572 3333 1683 4031
##      hcr_conserved
## [1,]          3350
 #    human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           4476          11393           23572 3333 1683 4031
#     hcr_conserved
#[1,]          3350


# Liver-Kidney
tissue_conserved_1_overlap(sort_humans_liver_kidney_DMRs_bed, sort_chimps_liver_kidney_DMRs_bed, sort_rhesus_liver_kidney_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87f7068e0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8652a9355.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85a481908.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a820de378c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87798f96a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8d62fc1f.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83afb265a.bed -d 0 -c 4 -o collapse
##  * Collapsing 8307 --> 8112 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8241d9a92.bed -d 0 -c 4 -o collapse
##  * Collapsing 6341 --> 6088 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8fafbce4.bed -d 0 -c 4 -o collapse
##  * Collapsing 7816 --> 7458 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a871b69d5d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a848ed027e.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84dc02c00.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83434febd.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87ca09386.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81a305919.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a853812980.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a879f6e00c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8458825dc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82ea5ca6c.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           7402          11956           26043 4360 2336 3719
##      hcr_conserved
## [1,]          3812
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           7402          11956           26043 4360 2336 3719
#     hcr_conserved
#[1,]          3812

# Lung-kidney
tissue_conserved_1_overlap(sort_humans_lung_kidney_DMRs_bed, sort_chimps_lung_kidney_DMRs_bed, sort_rhesus_lung_kidney_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a844fc6d62.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a838a4e028.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a831c1d23c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8550848d4.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a874c066fe.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87413cb48.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a840256ebc.bed -d 0 -c 4 -o collapse
##  * Collapsing 4701 --> 4598 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a837ebe0f2.bed -d 0 -c 4 -o collapse
##  * Collapsing 3401 --> 3306 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a847acac0c.bed -d 0 -c 4 -o collapse
##  * Collapsing 2736 --> 2663 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a877b240dc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a871623d9c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87ddb6b01.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a857b289c1.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8661f2f97.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87683b92d.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8eca0e64.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81f9a2668.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a867b16405.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8427dfae4.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]          10166           6361           11466 3027 1735 1095
##      hcr_conserved
## [1,]          1593
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]          10166           6361           11466 3027 1735 1095
#     hcr_conserved
#[1,]          1593

1% overlap in hypo methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hypo"),]

# Heart-kidney

tissue_conserved_1_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87a20fb8d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83d0af342.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86c065979.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87c9de99f.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a839a41d0a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84d5321b9.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86bb877f7.bed -d 0 -c 4 -o collapse
##  * Collapsing 3374 --> 3305 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87a7c3e88.bed -d 0 -c 4 -o collapse
##  * Collapsing 2424 --> 2329 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84aee35f8.bed -d 0 -c 4 -o collapse
##  * Collapsing 2002 --> 1939 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85d148d72.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8584778cb.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8158f1010.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a870c99941.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8508a9f91.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a816393889.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82336c659.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86aec8a10.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8117e9dad.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8a26f48c.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]           8337           3851            6633 2167 1191 803
##      hcr_conserved
## [1,]          1157
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]           8337           3851            6633 2167 1191 803
#     hcr_conserved
#[1,]          1157

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hypo"),]

tissue_conserved_1_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81f13237c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8282f560c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87ee12aa5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81155f31a.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85dfdfa8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84a91cb26.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a876d9e240.bed -d 0 -c 4 -o collapse
##  * Collapsing 5019 --> 4917 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87182a588.bed -d 0 -c 4 -o collapse
##  * Collapsing 4067 --> 3930 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8641cf46a.bed -d 0 -c 4 -o collapse
##  * Collapsing 5160 --> 4950 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8142dc5c0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84728e8c0.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8651315e4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8723e1875.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84106d891.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8191870ef.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81f67a61f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83a5c7176.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81c0a8918.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86e627917.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           5291           6148           12367 2427 1440 2452
##      hcr_conserved
## [1,]          2537
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           5291           6148           12367 2427 1440 2452
#     hcr_conserved
#[1,]          2537
     
     
# Heat lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_1_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83dad5929.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8ac1a3bf.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86dd1cb14.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a898d8280.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87d597596.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a88c66b82.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a836fa2698.bed -d 0 -c 4 -o collapse
##  * Collapsing 2113 --> 2080 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a838880d74.bed -d 0 -c 4 -o collapse
##  * Collapsing 994 --> 963 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a811889161.bed -d 0 -c 4 -o collapse
##  * Collapsing 885 --> 855 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87806fd2e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a869afdf4.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84a6aeccd.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84a8270bb.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83a48f22a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87299d638.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a878f408d3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84702d5b3.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a831986ef3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a89efce19.bed -wao
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           6922           2936            2734 1589 472 357
##      hcr_conserved
## [1,]           505
#     human_specific chimp_specific rhesus_specific   hc  hr  cr
#[1,]           6922           2936            2734 1589 472 357
#     hcr_conserved
#[1,]           505

# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_1_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8461f9c07.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8b9d4ad7.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82f1486f0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84c329590.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a836e0ce73.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86cf09dd3.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83efcc9cf.bed -d 0 -c 4 -o collapse
##  * Collapsing 4849 --> 4678 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83d05e6bb.bed -d 0 -c 4 -o collapse
##  * Collapsing 3487 --> 3267 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8612d72d9.bed -d 0 -c 4 -o collapse
##  * Collapsing 5066 --> 4708 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82b3cae48.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a821aba8e2.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a872f90f1e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83097bf1a.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82553feef.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8c893c49.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8567d1039.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81101f414.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a841cb33c5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85f910e2d.bed -wao
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           2380           7168           13737 2364 953 2392
##      hcr_conserved
## [1,]          2393
#     human_specific chimp_specific rhesus_specific   hc  hr   cr
#[1,]           2380           7168           13737 2364 953 2392
#     hcr_conserved
#[1,]          2393


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_1_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a841dc2d36.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85603e67.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87832fef7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a863ebcdd1.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86d111e94.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82243b425.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83fcc852.bed -d 0 -c 4 -o collapse
##  * Collapsing 3407 --> 3299 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81b6d6eb1.bed -d 0 -c 4 -o collapse
##  * Collapsing 2505 --> 2354 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a838aae40d.bed -d 0 -c 4 -o collapse
##  * Collapsing 3739 --> 3487 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a3086e6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81c6ba6e9.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8316d8cf9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84bebe22a.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87c4ac8fc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8247c1f1c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82ab2a0ca.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a861b40dc.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85e8efe56.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a811044dc7.bed -wao
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           2213           6412           14142 1761 816 1957
##      hcr_conserved
## [1,]          1578
#     human_specific chimp_specific rhesus_specific   hc  hr   cr
#[1,]           2213           6412           14142 1761 816 1957
#     hcr_conserved
#[1,]          1578

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_1_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a817044726.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8ffc13c5.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a877dc1cca.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82be3335e.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87375134b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8490e3a56.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82d1c73ae.bed -d 0 -c 4 -o collapse
##  * Collapsing 1053 --> 1030 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8361619b.bed -d 0 -c 4 -o collapse
##  * Collapsing 792 --> 779 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86cdd57c.bed -d 0 -c 4 -o collapse
##  * Collapsing 737 --> 722 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a830b169b0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82affc4da.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86363dc29.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a863f9aedb.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a3814c0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85cfd11ed.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8513daab8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a812e429e1.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82da7e6d8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a829533ded.bed -wao
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           2940           2478            4440 696 445 386
##      hcr_conserved
## [1,]           340
#     human_specific chimp_specific rhesus_specific  hc  hr  cr
#[1,]           2940           2478            4440 696 445 386
#     hcr_conserved
#[1,]           340

1% overlap in hyper methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hyper"),]

# Heart-kidney

tissue_conserved_1_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83c147094.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85028683d.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83875abe6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83750835c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8c10eb4f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a877078aed.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84559a3e6.bed -d 0 -c 4 -o collapse
##  * Collapsing 5243 --> 5103 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83e8add0.bed -d 0 -c 4 -o collapse
##  * Collapsing 3969 --> 3803 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a831d06159.bed -d 0 -c 4 -o collapse
##  * Collapsing 2896 --> 2791 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8574d14a3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86cb017bc.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83aba76b0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a813fcfa18.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83fba8895.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8b8c3b7b.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82f7bcdf4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84b9e816a.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a814384ea4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83f1417cd.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]          10493           3777            8595 3114 1814 812
##      hcr_conserved
## [1,]          2018
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]          10493           3777            8595 3114 1814 812
#     hcr_conserved
#[1,]          2018

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hyper"),]

tissue_conserved_1_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8b3a7e87.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86c94f01e.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a853113514.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8294f8889.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8d4cb606.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a838a8f13c.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8d4ea42e.bed -d 0 -c 4 -o collapse
##  * Collapsing 6166 --> 5941 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8786f156e.bed -d 0 -c 4 -o collapse
##  * Collapsing 4644 --> 4329 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a865398c68.bed -d 0 -c 4 -o collapse
##  * Collapsing 5743 --> 5331 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a822f24e6e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8572043ad.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8a51d22f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81ff7ea64.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85044ae2b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8ca037a9.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8c8e021c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8194b1f4c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85c253a73.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84ca8f4f9.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           3510           6851           15744 2924 1312 2308
##      hcr_conserved
## [1,]          3120
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           3510           6851           15744 2924 1312 2308
#     hcr_conserved
#[1,]          3120
     
     
# Heat lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_1_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a837baabdf.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84f3a7d11.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8779ffdd1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8ff138cd.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81c39acc5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8231e9123.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8489295e.bed -d 0 -c 4 -o collapse
##  * Collapsing 920 --> 902 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84dabfa11.bed -d 0 -c 4 -o collapse
##  * Collapsing 470 --> 466 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a839fbc28d.bed -d 0 -c 4 -o collapse
##  * Collapsing 432 --> 425 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86bb9abab.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8385c3d9f.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a816d61dfa.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8769abc5a.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83daa5ef0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8495bfd7d.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a849131da7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a852b888ce.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8641978c0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8139b18e7.bed -wao
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           3546           2005            2262 704 268 226
##      hcr_conserved
## [1,]           202
 #    human_specific chimp_specific rhesus_specific  hc  hr  cr
#[1,]           3546           2005            2262 704 268 226
#     hcr_conserved
#[1,]           202

# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_1_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84f24c4b3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8421524b2.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a865c061de.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84686908.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87b1f09c7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83229f1a7.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8326f87a5.bed -d 0 -c 4 -o collapse
##  * Collapsing 1929 --> 1905 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87a4a6ef9.bed -d 0 -c 4 -o collapse
##  * Collapsing 1606 --> 1573 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86172dd09.bed -d 0 -c 4 -o collapse
##  * Collapsing 2527 --> 2447 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a871f06437.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83182b154.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82f61d0e8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85beb4f2a.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82020b485.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8385c0245.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8416d29d7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87c5ad0c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a820472811.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a847c711c7.bed -wao
##      human_specific chimp_specific rhesus_specific  hc  hr   cr
## [1,]           2182           4349           10052 988 656 1527
##      hcr_conserved
## [1,]           926
#     human_specific chimp_specific rhesus_specific  hc  hr   cr
#[1,]           2182           4349           10052 988 656 1527
#     hcr_conserved
#[1,]           926


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_1_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8232d128d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8570abd5f.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a840044e73.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8cefdaec.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a826e196a0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8502d299e.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86a91cf5e.bed -d 0 -c 4 -o collapse
##  * Collapsing 4890 --> 4803 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a822d81a43.bed -d 0 -c 4 -o collapse
##  * Collapsing 3714 --> 3615 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86bfb3bb2.bed -d 0 -c 4 -o collapse
##  * Collapsing 3922 --> 3816 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a811e691a8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a842ecf476.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a822064084.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a842b6e329.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8625dffaf.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a839e3f653.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81cce9b30.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8407a165c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85afeda5e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87ab1f8b1.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           5288           5680           12146 2619 1431 1636
##      hcr_conserved
## [1,]          2204
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           5288           5680           12146 2619 1431 1636
#     hcr_conserved
#[1,]          2204

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_1_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8172f44af.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a833d484bd.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a822984396.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84ad7e93e.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83599b23d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a825244181.bed -wao
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84b19659.bed -d 0 -c 4 -o collapse
##  * Collapsing 3644 --> 3564 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86642c1a4.bed -d 0 -c 4 -o collapse
##  * Collapsing 2574 --> 2492 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81142f24b.bed -d 0 -c 4 -o collapse
##  * Collapsing 1966 --> 1908 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87d31c050.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8642aba3c.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a89ebf4e3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8274f4cd3.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8425ec4ee.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a826ed268e.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a841d8cee6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a853f50105.bed -wao
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8216073a8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85ec7251d.bed -wao
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]           7256           3911            7085 2336 1264 685
##      hcr_conserved
## [1,]          1244
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]           7256           3911            7085 2336 1264 685
#     hcr_conserved
#[1,]          1244

25% overlap

# Heart-kidney

tissue_conserved_25_overlap(sort_humans_heart_kidney_DMRs_bed, sort_chimps_heart_kidney_DMRs_bed, sort_rhesus_heart_kidney_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85d62be2f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85aa3d9c1.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a838a53491.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a821cf2b05.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a813a1b758.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86a00fed0.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8147c8c24.bed -d 0 -c 4 -o collapse
##  * Collapsing 7228 --> 7198 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a869c9f111.bed -d 0 -c 4 -o collapse
##  * Collapsing 4979 --> 4961 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a879da1778.bed -d 0 -c 4 -o collapse
##  * Collapsing 3732 --> 3712 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8747cf0ab.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a831dcc161.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a858113533.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82054a3a8.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85b3978d0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a812812a47.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85ea0f78b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a838a0bc66.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a816880a08.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83ccc3d39.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]          20415           9070           16631 4909 2672 1425
##      hcr_conserved
## [1,]          2295
#      human_specific chimp_specific rhesus_specific   hc   hr cr
#[1,]          20415           9070           16631 4909 2672 1425
#     hcr_conserved
#[1,]          2295

# Heart liver
tissue_conserved_25_overlap(sort_humans_heart_liver_DMRs_bed, sort_chimps_heart_liver_DMRs_bed, sort_rhesus_heart_liver_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a813f19d55.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a824584d6a.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85519383c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a875a0202.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a869a119cf.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a829af5ac9.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87227b0ef.bed -d 0 -c 4 -o collapse
##  * Collapsing 9434 --> 9382 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85c41bc09.bed -d 0 -c 4 -o collapse
##  * Collapsing 6402 --> 6354 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8a24ae5c.bed -d 0 -c 4 -o collapse
##  * Collapsing 8127 --> 8054 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a869abace4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a851832112.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a853d4709b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a828e036c4.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8fd8ecf8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81f58ed7b.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84c8c9ed7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8437367ca.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85aec0a25.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8e0bf537.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]          10676          15186           30727 5517 2489 4185
##      hcr_conserved
## [1,]          3879
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]          10676          15186           30727 5517 2489 4185
#     hcr_conserved
#[1,]          3879
     
     
# Heat lung
tissue_conserved_25_overlap(sort_humans_heart_lung_DMRs_bed, sort_chimps_heart_lung_DMRs_bed, sort_rhesus_heart_lung_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a865d1ef98.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86e85c72d.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a825e5ff09.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a873611be7.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8755f4060.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85a4dee55.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8424b81af.bed -d 0 -c 4 -o collapse
##  * Collapsing 2522 --> 2516 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8657920b8.bed -d 0 -c 4 -o collapse
##  * Collapsing 1099 --> 1093 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85f9a768b.bed -d 0 -c 4 -o collapse
##  * Collapsing 994 --> 987 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8772de8aa.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a849cfe32c.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85a12f590.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8650e5ff9.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a819057110.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a842eb92ed.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81a627c41.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84f5db8b8.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a860d61ad.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85635c034.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]          11053           5474            5399 2062 639 534
##      hcr_conserved
## [1,]           454
#     human_specific chimp_specific rhesus_specific   hc  hr  cr
#[1,]          11053           5474            5399 2062 639 534
#     hcr_conserved
#[1,]           454

# Liver lung
tissue_conserved_25_overlap(sort_humans_liver_lung_DMRs_bed, sort_chimps_liver_lung_DMRs_bed, sort_rhesus_liver_lung_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85702e17e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a863c2d08a.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81246c09f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a866dc6513.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8730856e8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81338dd19.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8600d1617.bed -d 0 -c 4 -o collapse
##  * Collapsing 5630 --> 5601 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8572f6685.bed -d 0 -c 4 -o collapse
##  * Collapsing 3690 --> 3658 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85f7f7d6a.bed -d 0 -c 4 -o collapse
##  * Collapsing 5506 --> 5452 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84a432e24.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a849cb3f73.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84ee1604c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85babe961.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82f2179d4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82b637194.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8692f8e66.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87760d74a.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a841d624da.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a878dcc97d.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           5752          13218           25690 3424 1481 3280
##      hcr_conserved
## [1,]          2185
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           5752          13218           25690 3424 1481 3280
#     hcr_conserved
#[1,]          2185

# Liver-Kidney
tissue_conserved_25_overlap(sort_humans_liver_kidney_DMRs_bed, sort_chimps_liver_kidney_DMRs_bed, sort_rhesus_liver_kidney_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8e34ccf1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86f76a0a9.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83c87a5de.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a871db5940.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85ad8b8a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86dcc4e69.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85150e8c8.bed -d 0 -c 4 -o collapse
##  * Collapsing 7017 --> 6987 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83caaa18.bed -d 0 -c 4 -o collapse
##  * Collapsing 4748 --> 4713 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82ce33e6e.bed -d 0 -c 4 -o collapse
##  * Collapsing 5722 --> 5669 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83d1eab91.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81d1a8ef8.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84cd77eb7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85aae4003.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a817601621.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a822918982.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83bcda914.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86969d18c.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8e375078.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84779b859.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           8851          13827           28164 4342 2068 3029
##      hcr_conserved
## [1,]          2649
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           5752          13218           25690 3424 1481 3280
#     hcr_conserved
#[1,]          2185

# Lung-kidney
tissue_conserved_25_overlap(sort_humans_lung_kidney_DMRs_bed, sort_chimps_lung_kidney_DMRs_bed, sort_rhesus_lung_kidney_DMRs_bed)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83ba9ea3e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81bd043bb.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a820bc299f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a824db3436.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83356d418.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81f0cb2e1.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a837a6edb4.bed -d 0 -c 4 -o collapse
##  * Collapsing 3930 --> 3919 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a831ca90e0.bed -d 0 -c 4 -o collapse
##  * Collapsing 2536 --> 2524 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86651ca93.bed -d 0 -c 4 -o collapse
##  * Collapsing 2071 --> 2062 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86bd4a5a4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a840cfe1.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83ca35aa2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85efc32b9.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85fdfbdb0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8795b6bcc.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83572255a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81a926eab.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a838cba72f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a846778815.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]          11201           7216           12424 2795 1400 940
##      hcr_conserved
## [1,]          1125
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]          11201           7216           12424 2795 1400 940
#     hcr_conserved
#[1,]          1125

25% overlap in hypo methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hypo"),]

# Heart-kidney

tissue_conserved_25_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8432824d4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86c102167.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84265ae59.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84d1f1f3c.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85687cbec.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81d346efc.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86a010237.bed -d 0 -c 4 -o collapse
##  * Collapsing 2795 --> 2786 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85d5f168d.bed -d 0 -c 4 -o collapse
##  * Collapsing 1866 --> 1860 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a827c65587.bed -d 0 -c 4 -o collapse
##  * Collapsing 1500 --> 1491 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85a2406d8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a845a74b75.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a876c5fe01.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8f2e8cf.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8f02f6a3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8311557a7.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85f72f117.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a861f9fc89.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8328a313d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86903e374.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]           9025           4520            7252 1964 1038 669
##      hcr_conserved
## [1,]           825
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]           9025           4520            7252 1964 1038 669
#     hcr_conserved
#[1,]           825

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hypo"),]

tissue_conserved_25_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8863594a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87670f40e.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85938f456.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81255a410.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a1d5bce.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85d0183bd.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8627fb0c0.bed -d 0 -c 4 -o collapse
##  * Collapsing 4244 --> 4231 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a875b5b5ae.bed -d 0 -c 4 -o collapse
##  * Collapsing 3070 --> 3057 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84a292d83.bed -d 0 -c 4 -o collapse
##  * Collapsing 3965 --> 3937 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86829e531.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8763c16fc.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85fdb866b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83e5006cf.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a843774921.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82ed06f77.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82b02f0af.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83ccc8523.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86cc60105.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82949cff9.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           6214           7204           13610 2421 1247 2126
##      hcr_conserved
## [1,]          1813
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           6214           7204           13610 2421 1247 2126
#     hcr_conserved
#[1,]          1813
     
     
# Heat lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_25_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8417e3154.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a841a4e00e.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86e72e46.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a864e8be1.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a812ab372.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8352266d7.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83f66c13d.bed -d 0 -c 4 -o collapse
##  * Collapsing 1772 --> 1768 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a858d8b191.bed -d 0 -c 4 -o collapse
##  * Collapsing 728 --> 723 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8471fcce5.bed -d 0 -c 4 -o collapse
##  * Collapsing 658 --> 653 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8350f734b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8e43d8c9.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8fa0293b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87f722203.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a870a5354.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87e1aeaf7.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87089445e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a812848b2c.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84a4d832d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86d262eae.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           7319           3287            3013 1446 401 332
##      hcr_conserved
## [1,]           322
#     human_specific chimp_specific rhesus_specific   hc  hr  cr
#[1,]           7319           3287            3013 1446 401 332
#     hcr_conserved
#[1,]           322

# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_25_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81d95bc7c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a818ed680.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a820df2fb1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86197e847.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83e52915c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a865826235.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8fa6a6e6.bed -d 0 -c 4 -o collapse
##  * Collapsing 4053 --> 4024 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a864064136.bed -d 0 -c 4 -o collapse
##  * Collapsing 2462 --> 2434 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84f5d081.bed -d 0 -c 4 -o collapse
##  * Collapsing 3522 --> 3477 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84c6ae3dc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a833b4c864.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8316ed558.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a858c06d0.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82b26811b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87d496008.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a841a96e5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a818b898d7.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86f88ee2c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a820d2324f.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           3188           8367           15115 2460 870 1918
##      hcr_conserved
## [1,]          1572
#     human_specific chimp_specific rhesus_specific   hc  hr   cr
#[1,]           3188           8367           15115 2460 870 1918
#     hcr_conserved
#[1,]          1572


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_25_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83b3f7788.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87c1850ac.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8f8840a4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a876e57544.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a820bccb33.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a812c014c1.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81754a80e.bed -d 0 -c 4 -o collapse
##  * Collapsing 2818 --> 2803 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a838b0277.bed -d 0 -c 4 -o collapse
##  * Collapsing 1773 --> 1753 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8545d965f.bed -d 0 -c 4 -o collapse
##  * Collapsing 2617 --> 2579 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a842048b08.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a817dd5db3.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82295f5b7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a872275581.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a864274dd.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8638f5e71.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a865fc5e08.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86e0b3d5.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83fc0f0f7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83d2f6608.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           2841           7349           15184 1772 722 1554
##      hcr_conserved
## [1,]          1033
#     human_specific chimp_specific rhesus_specific   hc  hr   cr
#[1,]           2841           7349           15184 1772 722 1554
#     hcr_conserved
#[1,]          1033

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_25_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a853ae35b1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87b802b5e.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a4b4338.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a884e9406.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86ca05ba9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a896662f3.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8742cbca2.bed -d 0 -c 4 -o collapse
##  * Collapsing 847 --> 845 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85f8e5060.bed -d 0 -c 4 -o collapse
##  * Collapsing 579 --> 577 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87001225a.bed -d 0 -c 4 -o collapse
##  * Collapsing 551 --> 550 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8570228ec.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a836c5b952.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8291e1225.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8632cb7d.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83cd07690.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8b40dd25.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81c841c27.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84453118e.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83a57a18f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81e227774.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           3232           2738            4717 612 344 317
##      hcr_conserved
## [1,]           233
#     human_specific chimp_specific rhesus_specific  hc  hr  cr
#[1,]           3232           2738            4717 612 344 317
#     hcr_conserved
#[1,]           233

25% overlap in hyper methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hyper"),]

# Heart-kidney

tissue_conserved_25_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85a1746c2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81a060e73.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a828b6661e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86d6defc4.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8571367e9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8429e21c4.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8d1f74ca.bed -d 0 -c 4 -o collapse
##  * Collapsing 4430 --> 4409 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83da89b65.bed -d 0 -c 4 -o collapse
##  * Collapsing 3065 --> 3053 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87d7971c9.bed -d 0 -c 4 -o collapse
##  * Collapsing 2196 --> 2185 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a89e2a1c9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a833f55814.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87fb3a9f0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a850864b33.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81aa9475e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82dc7de39.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87510428d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a872be52c2.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8624fe390.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a878d5a2b5.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]          11434           4582            9456 2949 1593 727
##      hcr_conserved
## [1,]          1463
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]          11434           4582            9456 2949 1593 727
#     hcr_conserved
#[1,]          1463

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hyper"),]

tissue_conserved_25_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81192610.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8a28738c.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86aacebe1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86980e1e8.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a852976bd1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86f99e509.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81f8acc9.bed -d 0 -c 4 -o collapse
##  * Collapsing 5176 --> 5137 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83288957b.bed -d 0 -c 4 -o collapse
##  * Collapsing 3232 --> 3198 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82fea3d19.bed -d 0 -c 4 -o collapse
##  * Collapsing 4064 --> 4020 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82fae059b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81c1ad3c6.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a810ccfdf9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a872176e4e.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a863f03269.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84d0bd52c.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85eecb122.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a824acb940.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82b5632a7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81c38f94e.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           4545           8063           17283 3112 1173 1992
##      hcr_conserved
## [1,]          2036
#    human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           4545           8063           17283 3112 1173 1992
#     hcr_conserved
#[1,]          2036
     
     
# Heat lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_25_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83fe0f5a9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a876d12a61.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a844e4777f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a825c9d3f1.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8204f2bd2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84014fab1.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83ceffa8c.bed -d 0 -c 4 -o collapse
##  * Collapsing 747 --> 745 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a875ba9263.bed -d 0 -c 4 -o collapse
##  * Collapsing 354 --> 353 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8380c99a2.bed -d 0 -c 4 -o collapse
##  * Collapsing 328 --> 326 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8370ef33f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a862bdbc8f.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86259e73c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85bc5e0a1.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87616adc6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a827becb0e.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86631a79a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a859006c3b.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87b8069f9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8755da7e9.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           3752           2196            2409 615 223 196
##      hcr_conserved
## [1,]           130
#     human_specific chimp_specific rhesus_specific  hc  hr  cr
#[1,]           3752           2196            2409 615 223 196
#     hcr_conserved
#[1,]           130

# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_25_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8297188d3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a877505dc1.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8613ba0ee.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8f4590fe.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8207ea621.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85d1d9b84.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82ab2db15.bed -d 0 -c 4 -o collapse
##  * Collapsing 1572 --> 1572 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8312ed2d7.bed -d 0 -c 4 -o collapse
##  * Collapsing 1167 --> 1163 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81f0b5db0.bed -d 0 -c 4 -o collapse
##  * Collapsing 1904 --> 1895 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83d9bca0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a867953796.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85953730c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84a1b5963.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86f012321.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82c0816d8.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a837e1bd40.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87c79e962.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85f40b97e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85b891e16.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific  hc  hr   cr
## [1,]           2621           4927           10707 968 559 1291
##      hcr_conserved
## [1,]           604
#     human_specific chimp_specific rhesus_specific  hc  hr   cr
#[1,]           2621           4927           10707 968 559 1291
#     hcr_conserved
#[1,]           604


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_25_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83e5578db.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8774d22a6.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85278f214.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a875c7b0cb.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85b290736.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a831af9f1.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a88e477a7.bed -d 0 -c 4 -o collapse
##  * Collapsing 4194 --> 4179 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a818f5eb3c.bed -d 0 -c 4 -o collapse
##  * Collapsing 2906 --> 2891 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Bedtools requires sorted input for merging!
##    Your data is being automatically sorted
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81e3e8f87.bed -d 0 -c 4 -o collapse
##  * Collapsing 3029 --> 3014 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87bd1af5c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8ee2657e.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81269d7b3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81782e8b1.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82a991576.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82db86981.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a815f704de.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a860f310a6.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86d240f9f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85b30ba6e.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr   cr
## [1,]           6073           6548           13114 2576 1288 1410
##      hcr_conserved
## [1,]          1605
#     human_specific chimp_specific rhesus_specific   hc   hr   cr
#[1,]           6073           6548           13114 2576 1288 1410
#     hcr_conserved
#[1,]          1605

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_25_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8531955df.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8375edcde.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87856fa39.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8b8550d7.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a848b77f08.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8728e0597.bed -wao -f 0.25 -F 0.25
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83042f40b.bed -d 0 -c 4 -o collapse
##  * Collapsing 3081 --> 3072 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a851dd6105.bed -d 0 -c 4 -o collapse
##  * Collapsing 1940 --> 1930 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82e5627a6.bed -d 0 -c 4 -o collapse
##  * Collapsing 1502 --> 1494 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a864583f31.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8311ba999.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a877dfc5c0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82c5f77dd.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a871f75ca3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87b8d1931.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a846e963ff.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83be2e395.bed -wao -f 0.25 -F 0.25
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... FAIL
##    The input for object has overlapping features!
##    This can cause unexpected results for some set operations.
##    i.e. x <- bedr.merge.region(x)
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a870fe1f3c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82da9852f.bed -wao -f 0.25 -F 0.25
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]           7985           4495            7739 2184 1042 608
##      hcr_conserved
## [1,]           889
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]           7985           4495            7739 2184 1042 608
#     hcr_conserved
#[1,]           889

50% overlap

50% overlap in hypo methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hypo"),]

# Heart-kidney

tissue_conserved_50_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a836c9b6ba.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81cc315.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83f8c3462.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8731c969e.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8a5a7336.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82f80a27a.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a855242e18.bed -d 0 -c 4 -o collapse
##  * Collapsing 1958 --> 1958 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86cc3da0c.bed -d 0 -c 4 -o collapse
##  * Collapsing 1075 --> 1075 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8581d8213.bed -d 0 -c 4 -o collapse
##  * Collapsing 880 --> 880 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8629198d6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82b8ef94a.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8107ec3ec.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84141617f.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84104a55e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8635e1d25.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a876e3bcf5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a816f82f89.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8249a70a0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8689d5252.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]          10210           5531            8220 1567 684 489
##      hcr_conserved
## [1,]           391
#     human_specific chimp_specific rhesus_specific   hc  hr  cr hcr_conserved
#          10210           5531            8220 1567 684 489           391

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hypo"),]

tissue_conserved_50_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84853fb70.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82fd62841.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83a300e10.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a855963563.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82a23d49.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86ddf7459.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a870928482.bed -d 0 -c 4 -o collapse
##  * Collapsing 2985 --> 2985 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81f6eebbe.bed -d 0 -c 4 -o collapse
##  * Collapsing 1816 --> 1816 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82dcb7341.bed -d 0 -c 4 -o collapse
##  * Collapsing 2430 --> 2430 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a868f5ab3f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a860a459cd.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83236cb98.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a810d5dab0.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a854bd2bae.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8271c6823.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86b9e3732.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8c41784e.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82958127f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8301b6345.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           7751           9006           15407 2128 959 1573
##      hcr_conserved
## [1,]           857
#     human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#           7751           9006           15407 2128 959 1573           857
     
     
# Heat lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_50_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82896140f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85214e121.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a827917283.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85cc4f24d.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a850e0f3d7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85e50eaf4.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a853c86fc9.bed -d 0 -c 4 -o collapse
##  * Collapsing 1159 --> 1159 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a856100de1.bed -d 0 -c 4 -o collapse
##  * Collapsing 425 --> 425 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85daa1705.bed -d 0 -c 4 -o collapse
##  * Collapsing 371 --> 371 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a847fdd829.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82f1c7702.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a851d2c44.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a817f16d74.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8513324ea.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a811c862cf.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84a7a413.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8170411f.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85227488c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82231e82f.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           8060           4013            3428 1003 269 215
##      hcr_conserved
## [1,]           156
#     human_specific chimp_specific rhesus_specific   hc  hr  cr hcr_conserved
#           8060           4013            3428 1003 269 215           156



# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_50_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a837bce381.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8534c2a4b.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86287e4ab.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8338407ca.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a858794465.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87fcbbdc1.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a837f0b7e3.bed -d 0 -c 4 -o collapse
##  * Collapsing 2780 --> 2780 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8226441e5.bed -d 0 -c 4 -o collapse
##  * Collapsing 1364 --> 1364 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81440246.bed -d 0 -c 4 -o collapse
##  * Collapsing 1961 --> 1961 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8252bc7fb.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81cfc5489.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87e858b6c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82ad74e5.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8414ae163.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a817026b2f.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8710c43c1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8354d859b.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8e8e0567.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a849a42f0f.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           4606          10236           16810 2120 704 1301
##      hcr_conserved
## [1,]           660
#     human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#           4606          10236           16810 2120 704 1301           660


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_50_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83727c72f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a826d16594.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a851df4a6d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83e0f4602.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8584e31d7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8672f0faa.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81288d731.bed -d 0 -c 4 -o collapse
##  * Collapsing 1908 --> 1908 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a868f9cf57.bed -d 0 -c 4 -o collapse
##  * Collapsing 931 --> 931 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83caed2cf.bed -d 0 -c 4 -o collapse
##  * Collapsing 1445 --> 1445 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a865a6f775.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86a3c75bf.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8482aed1c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8393d8d64.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81de8571b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86f5e25c6.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83cdf7828.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a850beadb7.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8192c140e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81cdd95eb.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           3953           8779           16541 1484 507 1021
##      hcr_conserved
## [1,]           424
#    human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#           3953           8779           16541 1484 507 1021           424

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_50_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8395a946a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87c9b421c.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81031198e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a847882098.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81afe7e81.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a841548286.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82abd23d6.bed -d 0 -c 4 -o collapse
##  * Collapsing 570 --> 570 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a870b064d6.bed -d 0 -c 4 -o collapse
##  * Collapsing 338 --> 338 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8469e10dd.bed -d 0 -c 4 -o collapse
##  * Collapsing 327 --> 327 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a832a7a953.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8667dba74.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a870365a52.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84829707c.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a821de4a2a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86cde66c3.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81d382558.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a845aad154.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82a1ff57e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8aee2a80.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           3625           3115            5058 458 226 215
##      hcr_conserved
## [1,]           112
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#           3625           3115            5058 458 226 215           112

50% overlap in hyper methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hyper"),]

# Heart-kidney

tissue_conserved_50_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86945a14.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8298a7f7e.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a846843587.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a832d16bd2.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8417979e7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a813799853.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a869ecff6f.bed -d 0 -c 4 -o collapse
##  * Collapsing 3114 --> 3114 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86eb4866e.bed -d 0 -c 4 -o collapse
##  * Collapsing 1846 --> 1846 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86ceb5326.bed -d 0 -c 4 -o collapse
##  * Collapsing 1308 --> 1308 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a871cdcd18.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82f64a113.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a830e9c7c7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81c9a91cd.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a848234bbb.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a855fbd22f.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8343dfd9d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a841a5eb77.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a843843055.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82b4d1a76.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc   hr  cr
## [1,]          13154           5974           10760 2439 1171 633
##      hcr_conserved
## [1,]           675
#     human_specific chimp_specific rhesus_specific   hc   hr  cr hcr_conserved
#          13154           5974           10760     2439 1171 633           675

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hyper"),]

tissue_conserved_50_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84d34ac93.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8d04579a.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85c75a906.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8467339ed.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8203dd936.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8540da5.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8123148b7.bed -d 0 -c 4 -o collapse
##  * Collapsing 3641 --> 3641 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a863d8624.bed -d 0 -c 4 -o collapse
##  * Collapsing 1829 --> 1829 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a833399264.bed -d 0 -c 4 -o collapse
##  * Collapsing 2276 --> 2276 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86658f60a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87532dc66.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a829a9acbd.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84b78729a.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84b353e9b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81fd31006.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8150293d5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a827a5807b.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8637e90c6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8684571b8.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           6271          10161           19254 2766 954 1401
##      hcr_conserved
## [1,]           875
#     human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#           6271          10161           19254     2766 954 1401           875
     
     
# Heart lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_50_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82496ba59.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87a3c4e1a.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8128a4de6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a820fee527.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a841d5f6e6.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a869c2f1.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85f3f0841.bed -d 0 -c 4 -o collapse
##  * Collapsing 469 --> 469 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87512c976.bed -d 0 -c 4 -o collapse
##  * Collapsing 204 --> 204 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8505eae96.bed -d 0 -c 4 -o collapse
##  * Collapsing 187 --> 187 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87831bfc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87bc1252f.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83dcf89fb.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a846c1f36e.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8430e3fa7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83ce41138.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a855eea5ac.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85d7c4a48.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8205eb4ae.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a812838a1d.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           4099           2533            2619 417 152 135
##      hcr_conserved
## [1,]            52
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#          4099           2533            2619      417 152 135            52

# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_50_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83b03c73a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8671c5cad.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a862e305f0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a863b572ff.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8db1f876.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8157e054e.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a81ade63ae.bed -d 0 -c 4 -o collapse
##  * Collapsing 1029 --> 1029 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a864ee0771.bed -d 0 -c 4 -o collapse
##  * Collapsing 677 --> 677 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8478148bd.bed -d 0 -c 4 -o collapse
##  * Collapsing 1123 --> 1123 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8e983628.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86507e1d8.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82d2a732d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a825a98335.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81830018a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82da6bc6d.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86d5883bd.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8744f238.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a827b51585.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a833086464.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           3318           5910           11633 757 405 851
##      hcr_conserved
## [1,]           272
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#           3318           5910           11633     757 405 851           272


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_50_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84f9bcef8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8599027b4.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86b373a65.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86c42a126.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84cb77386.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a857e0a11a.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87642b5a1.bed -d 0 -c 4 -o collapse
##  * Collapsing 3012 --> 3012 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86617bb41.bed -d 0 -c 4 -o collapse
##  * Collapsing 1768 --> 1768 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82287d849.bed -d 0 -c 4 -o collapse
##  * Collapsing 1825 --> 1825 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a820bdd0f0.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83d94b3bb.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86502e210.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a875177ba2.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a814046bd.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8310ff2d8.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8b285648.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8450fc67a.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8791e2415.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a871521982.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr   cr
## [1,]           7564           8104           14626 2210 966 1023
##      hcr_conserved
## [1,]           802
#     human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#           7564           8104           14626     2210 966 1023           802

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_50_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a894926bb.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85bb8a8ae.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a8bffdd.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a878114243.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a837c46b4d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87bc506de.bed -wao -f 0.5 -F 0.5
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a855e58a3f.bed -d 0 -c 4 -o collapse
##  * Collapsing 2128 --> 2128 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86a5fdfe7.bed -d 0 -c 4 -o collapse
##  * Collapsing 1143 --> 1143 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a861423ba.bed -d 0 -c 4 -o collapse
##  * Collapsing 897 --> 897 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87da11475.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a815d90876.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a833839429.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a824fbd8e.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84b3434a8.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82f8c9417.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86207a5c1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a862e29439.bed -wao -f 0.5 -F 0.5
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82d1cc4f4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87e393297.bed -wao -f 0.5 -F 0.5
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           9239           5561            8648 1718 733 487
##      hcr_conserved
## [1,]           410
#    human_specific chimp_specific rhesus_specific   hc  hr  cr hcr_conserved
#           9239           5561            8648     1718 733 487           410

75% overlap

75% overlap in hypo methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hypo"),]

# Heart-kidney

tissue_conserved_75_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a873f7003d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a823c2d79e.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a835fe5f7f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8395d88dc.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a878d94a51.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84955cc3f.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8305b040d.bed -d 0 -c 4 -o collapse
##  * Collapsing 897 --> 897 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85dd4112d.bed -d 0 -c 4 -o collapse
##  * Collapsing 399 --> 399 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8187de944.bed -d 0 -c 4 -o collapse
##  * Collapsing 293 --> 293 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82d91fead.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a847f6ffea.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85af6a999.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a836231560.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a866a19dab.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a837b705da.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84b01a514.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a869473b66.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81ec06004.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8bac7bf7.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]          11629           6861            9165 824 326 220
##      hcr_conserved
## [1,]            73
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#          11629           6861            9165     824 326 220            73

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hypo"),]

tissue_conserved_75_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8ee225b5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86ea98a1f.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86649dbb1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8d075187.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86753fea2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81928f3ea.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87fbbddd4.bed -d 0 -c 4 -o collapse
##  * Collapsing 1411 --> 1411 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a810232137.bed -d 0 -c 4 -o collapse
##  * Collapsing 637 --> 637 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85cb22117.bed -d 0 -c 4 -o collapse
##  * Collapsing 898 --> 898 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84eb51d28.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87a2d5dfe.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8587eaca5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82c3031f4.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82d39d5de.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87595b756.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a69343b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a828d9834a.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87d59c254.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a858695a8c.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           9826          11434           17440 1232 458 719
##      hcr_conserved
## [1,]           179
#    human_specific chimp_specific rhesus_specific   hc  hr  cr hcr_conserved
#           9826          11434           17440     1232 458 719           179
     
# Heart lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_75_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83705b298.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84c0dbd3c.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a832252821.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82df002e8.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a868f44402.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8417acba7.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82cf47f1f.bed -d 0 -c 4 -o collapse
##  * Collapsing 516 --> 516 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a870cc7f8a.bed -d 0 -c 4 -o collapse
##  * Collapsing 146 --> 146 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8519baeb1.bed -d 0 -c 4 -o collapse
##  * Collapsing 145 --> 145 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84486ddd5.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85a67a147.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87043dc61.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87fc1f820.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85d89a10e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8698e5ebc.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8297adc7f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8136ae6b1.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81fcf821c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87c5d60f1.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           8858           4758            3809 484 114 113
##      hcr_conserved
## [1,]            32
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#           8858           4758            3809     484 114 113            32



# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hypo"),]

tissue_conserved_75_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83288966f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86a620c6e.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87aa267.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a850e8716.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8609f708f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86601b80f.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a845469cf9.bed -d 0 -c 4 -o collapse
##  * Collapsing 1371 --> 1371 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a884cf5fd.bed -d 0 -c 4 -o collapse
##  * Collapsing 442 --> 442 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a832c4686a.bed -d 0 -c 4 -o collapse
##  * Collapsing 693 --> 693 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a88c5e185.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87ff585a1.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a833ad3382.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a865660f3b.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a855899946.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8649e586.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8526408de.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a861b3ed1b.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81cf244e4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82480d264.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           6407          12383           18470 1241 312 563
##      hcr_conserved
## [1,]           130
#     human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#           6407          12383           18470     1241 312 563           130


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_75_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87f9e8606.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81e23a894.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81a0f5391.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8137b25b0.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8403d82d2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83cb14cd0.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8c2c2dc9.bed -d 0 -c 4 -o collapse
##  * Collapsing 915 --> 915 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a84f968969.bed -d 0 -c 4 -o collapse
##  * Collapsing 310 --> 310 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8172b5a.bed -d 0 -c 4 -o collapse
##  * Collapsing 473 --> 473 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8622bb90c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a829259509.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a829839bb3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8297e85b9.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a844b11507.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a81023e8a3.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84774cdc7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87b834580.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a870cb9a17.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83c8a078.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           5224          10401           17791 834 229 392
##      hcr_conserved
## [1,]            81
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#           5224          10401           17791     834 229 392            81

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hypo"),]

tissue_conserved_75_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a839848c03.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83107a4b9.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87772037e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8735086b9.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a85f275cb4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8273894e0.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a836679e24.bed -d 0 -c 4 -o collapse
##  * Collapsing 241 --> 241 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82aa009f2.bed -d 0 -c 4 -o collapse
##  * Collapsing 122 --> 122 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a858d18941.bed -d 0 -c 4 -o collapse
##  * Collapsing 115 --> 115 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a852689e8c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8398d2c70.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8121261d1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a855c0e35.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87083626d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8366ea7fd.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81ba67b28.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86959cea0.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a827ee2d41.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a836eef67a.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific  hc  hr cr
## [1,]           4075           3561            5391 224 105 98
##      hcr_conserved
## [1,]            17
#     human_specific chimp_specific rhesus_specific  hc  hr cr hcr_conserved
#           4075           3561            5391 224 105 98            17

75% overlap in hyper methylated

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hyper"),]

# Heart-kidney

tissue_conserved_75_overlap(sort_humans_heart_kidney_DMRs_bed_hypo, sort_chimps_heart_kidney_DMRs_bed_hypo, sort_rhesus_heart_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8383622d4.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8154f3921.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8113a97dc.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a813fb346a.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87e05b949.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85dbf3c34.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a83478435e.bed -d 0 -c 4 -o collapse
##  * Collapsing 1501 --> 1501 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85bf59123.bed -d 0 -c 4 -o collapse
##  * Collapsing 664 --> 664 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8446a2afe.bed -d 0 -c 4 -o collapse
##  * Collapsing 470 --> 470 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8224e5b9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8347cc5c1.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83741322d.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8be4f39a.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a854d0bda1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a852862ca9.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a824e77404.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a854e29324.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81dcaa66e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a837bdb805.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]          15427           7903           12258 1348 511 317
##      hcr_conserved
## [1,]           153
#     human_specific chimp_specific rhesus_specific   hc   hr  cr hcr_conserved
#                15427           7903           12258 1348 511 317           153

# Heart liver

sort_humans_heart_liver_DMRs_bed_hypo <- sort_humans_heart_liver_DMRs_bed[which(sort_humans_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_liver_DMRs_bed_hypo <- sort_chimps_heart_liver_DMRs_bed[which(sort_chimps_heart_liver_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_liver_DMRs_bed_hypo <- sort_rhesus_heart_liver_DMRs_bed[which(sort_rhesus_heart_liver_DMRs_bed[,4] == "hyper"),]

tissue_conserved_75_overlap(sort_humans_heart_liver_DMRs_bed_hypo, sort_chimps_heart_liver_DMRs_bed_hypo, sort_rhesus_heart_liver_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84d259ec3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a833e8254.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86c0c72b2.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a827f329c.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a84339b16a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84ac572d.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82239a08b.bed -d 0 -c 4 -o collapse
##  * Collapsing 1836 --> 1836 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82f521d07.bed -d 0 -c 4 -o collapse
##  * Collapsing 625 --> 625 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a860f4604a.bed -d 0 -c 4 -o collapse
##  * Collapsing 771 --> 771 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83dffbf40.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a847e0e40c.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a841bd2dcb.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a861e96ca8.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a849f18bd7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a846444150.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a851052244.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85c33d816.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87a862357.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a83b37d47b.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           8581          12772           21264 1660 449 595
##      hcr_conserved
## [1,]           176
#     human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#                8581          12772           21264 1660 449 595           176
     
     
# Heart lung

sort_humans_heart_lung_DMRs_bed_hypo <- sort_humans_heart_lung_DMRs_bed[which(sort_humans_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_lung_DMRs_bed_hypo <- sort_chimps_heart_lung_DMRs_bed[which(sort_chimps_heart_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_lung_DMRs_bed_hypo <- sort_rhesus_heart_lung_DMRs_bed[which(sort_rhesus_heart_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_75_overlap(sort_humans_heart_lung_DMRs_bed_hypo, sort_chimps_heart_lung_DMRs_bed_hypo, sort_rhesus_heart_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a865c19968.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84a682068.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a9a35ce.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87faca465.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87c76e624.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a845310b2f.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a812181c80.bed -d 0 -c 4 -o collapse
##  * Collapsing 189 --> 189 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8548920b4.bed -d 0 -c 4 -o collapse
##  * Collapsing 65 --> 65 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8481731ba.bed -d 0 -c 4 -o collapse
##  * Collapsing 56 --> 56 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83380f678.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8249c2c7f.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8b9b5be.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8ee508d9.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a840767223.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a820d099a9.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a848aa560b.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a862f75982.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81a83bd9a.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85a2e09e4.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific  hc hr cr hcr_conserved
## [1,]           4475           2901            2846 180 56 47             9
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#           4475           2901            2846       180 56 47             9

# Liver lung
sort_humans_liver_lung_DMRs_bed_hypo <- sort_humans_liver_lung_DMRs_bed[which(sort_humans_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_lung_DMRs_bed_hypo <- sort_chimps_liver_lung_DMRs_bed[which(sort_chimps_liver_lung_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_lung_DMRs_bed_hypo <- sort_rhesus_liver_lung_DMRs_bed[which(sort_rhesus_liver_lung_DMRs_bed[,4] == "hyper"),]

tissue_conserved_75_overlap(sort_humans_liver_lung_DMRs_bed_hypo, sort_chimps_liver_lung_DMRs_bed_hypo, sort_rhesus_liver_lung_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a835cb8148.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8677ac895.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8468bb604.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87ce1fce8.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a859aff211.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a86ab3449e.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a85a6c622a.bed -d 0 -c 4 -o collapse
##  * Collapsing 483 --> 483 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86946d0a6.bed -d 0 -c 4 -o collapse
##  * Collapsing 214 --> 214 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87f8d1539.bed -d 0 -c 4 -o collapse
##  * Collapsing 399 --> 399 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a854f9212e.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8218ecfcd.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86a92241c.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a826adf3aa.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a834e9bac7.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82fd94061.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8fe757b9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8b4cfbd5.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a83b4187bf.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8180f926b.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]           4107           6960           12600 431 162 347
##      hcr_conserved
## [1,]            52
#     human_specific chimp_specific rhesus_specific  hc  hr  cr hcr_conserved
#           4107           6960           12600     431 162 347            52


# Liver-Kidney
sort_humans_liver_kidney_DMRs_bed_hypo <- sort_humans_liver_kidney_DMRs_bed[which(sort_humans_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_liver_kidney_DMRs_bed_hypo <- sort_chimps_liver_kidney_DMRs_bed[which(sort_chimps_liver_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_liver_kidney_DMRs_bed_hypo <- sort_rhesus_liver_kidney_DMRs_bed[which(sort_rhesus_liver_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_75_overlap(sort_humans_liver_kidney_DMRs_bed_hypo, sort_chimps_liver_kidney_DMRs_bed_hypo, sort_rhesus_liver_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8383e3544.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a836a0337a.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a825de23d3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a831d01373.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8334a49d1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82eb94efe.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a866d24651.bed -d 0 -c 4 -o collapse
##  * Collapsing 1447 --> 1447 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a8551eebf1.bed -d 0 -c 4 -o collapse
##  * Collapsing 646 --> 646 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a87a390c43.bed -d 0 -c 4 -o collapse
##  * Collapsing 706 --> 706 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a82ed79499.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84957a89b.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86ece0c34.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a869c0d171.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a818d8d258.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a82ccbb1e4.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a820040765.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a819c61727.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a830d2616f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8270802df.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific   hc  hr  cr
## [1,]           9641          10178           16257 1255 454 514
##      hcr_conserved
## [1,]           192
#     human_specific chimp_specific rhesus_specific   hc  hr   cr hcr_conserved
#          9641          10178           16257        1255 454 514           192

# Lung-kidney

sort_humans_lung_kidney_DMRs_bed_hypo <- sort_humans_lung_kidney_DMRs_bed[which(sort_humans_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_lung_kidney_DMRs_bed_hypo <- sort_chimps_lung_kidney_DMRs_bed[which(sort_chimps_lung_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_lung_kidney_DMRs_bed_hypo <- sort_rhesus_lung_kidney_DMRs_bed[which(sort_rhesus_lung_kidney_DMRs_bed[,4] == "hyper"),]

tissue_conserved_75_overlap(sort_humans_lung_kidney_DMRs_bed_hypo, sort_chimps_lung_kidney_DMRs_bed_hypo, sort_rhesus_lung_kidney_DMRs_bed_hypo)
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a8429f4757.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84e79fbef.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a86dd03ae9.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a84c9f3bae.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a81259de60.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a87413bb6b.bed -wao -f 0.75 -F 0.75
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a829c06b99.bed -d 0 -c 4 -o collapse
##  * Collapsing 999 --> 999 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a86de9e369.bed -d 0 -c 4 -o collapse
##  * Collapsing 405 --> 405 regions... NOTE
## MERGING
## VALIDATE REGIONS
##  * Checking input type... PASS
##    Input is in bed format
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Processing input (1): i
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
##    bedtools merge -i /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/i_144a82ef011eb.bed -d 0 -c 4 -o collapse
##  * Collapsing 330 --> 330 regions... NOTE
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a827fd7c3f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8449924fe.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a870124ea1.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8361e5ef5.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a831928965.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a8362e5c1a.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a852b40e8f.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a85b1f233d.bed -wao -f 0.75 -F 0.75
##  * Processing input (1): a
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##  * Processing input (2): b
## CONVERT TO BED
##  * Checking input type... PASS
##    Input is in bed format
## VALIDATE REGIONS
##  * Check if index is a string... PASS
##  * Check index pattern... PASS
##  * Check for missing values... PASS
##  * Check for larger start position... PASS.
##  * Check if zero based... PASS
##  * Checking sort order... PASS
##  * Checking for overlapping 'contiguous' regions... PASS
##    bedtools intersect -a /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/a_144a87e86f6b3.bed -b /var/folders/rf/qrcw6ncj05z1pc_pq9xzw3540000gn/T//Rtmp6XZ1WI/b_144a847b72a92.bed -wao -f 0.75 -F 0.75
##      human_specific chimp_specific rhesus_specific  hc  hr  cr
## [1,]          10783           6934            9630 912 318 243
##      hcr_conserved
## [1,]            87
#    human_specific chimp_specific rhesus_specific   hc  hr  cr hcr_conserved
#          10783           6934            9630       912 318 243            87

Making plots

# Hypo
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]           9025           4520            7252 1964 1038 669
#     hcr_conserved
#[1,]           825

sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hypo"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hypo"),]

# Heart-kidney hypo
dev.off()
## null device 
##           1
draw.triple.venn(nrow(sort_humans_heart_kidney_DMRs_bed_hypo), nrow(sort_chimps_heart_kidney_DMRs_bed_hypo), nrow(sort_rhesus_heart_kidney_DMRs_bed_hypo), 1964+825, 669+825, 1038+825, 825,  main= "Heart versus kidney (hypomethylated)",  category = c("Human", "Chimp", "Rhesus macaque"), height=3000, width=3000, cex=2 , fill = pal[1:3], lty=1, cat.cex = 2, main.cex = 2)
## (polygon[GRID.polygon.1], polygon[GRID.polygon.2], polygon[GRID.polygon.3], polygon[GRID.polygon.4], polygon[GRID.polygon.5], polygon[GRID.polygon.6], text[GRID.text.7], text[GRID.text.8], text[GRID.text.9], text[GRID.text.10], text[GRID.text.11], text[GRID.text.12], text[GRID.text.13], text[GRID.text.14], text[GRID.text.15], text[GRID.text.16])
#Hyper
#     human_specific chimp_specific rhesus_specific   hc   hr  cr
#[1,]          11434           4582            9456 2949 1593 727
#     hcr_conserved
#[1,]          1463


sort_humans_heart_kidney_DMRs_bed_hypo <- sort_humans_heart_kidney_DMRs_bed[which(sort_humans_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_chimps_heart_kidney_DMRs_bed_hypo <- sort_chimps_heart_kidney_DMRs_bed[which(sort_chimps_heart_kidney_DMRs_bed[,4] == "hyper"),]

sort_rhesus_heart_kidney_DMRs_bed_hypo <- sort_rhesus_heart_kidney_DMRs_bed[which(sort_rhesus_heart_kidney_DMRs_bed[,4] == "hyper"),]

# # Other plots
dev.off()
## null device 
##           1
draw.triple.venn(nrow(sort_humans_heart_kidney_DMRs_bed_hypo), nrow(sort_chimps_heart_kidney_DMRs_bed_hypo), nrow(sort_rhesus_heart_kidney_DMRs_bed_hypo), 2949+1463, 727+1463, 1593+1463, 1463,  main= "Heart versus kidney (hypomethylated)",  category = c("Human", "Chimp", "Rhesus macaque"), height=3000, width=3000, cex=2 , fill = pal[1:3], lty=1, cat.cex = 2, main.cex = 2)
## (polygon[GRID.polygon.17], polygon[GRID.polygon.18], polygon[GRID.polygon.19], polygon[GRID.polygon.20], polygon[GRID.polygon.21], polygon[GRID.polygon.22], text[GRID.text.23], text[GRID.text.24], text[GRID.text.25], text[GRID.text.26], text[GRID.text.27], text[GRID.text.28], text[GRID.text.29], text[GRID.text.30], text[GRID.text.31], text[GRID.text.32])
dev.off()
## null device 
##           1
draw.triple.venn(444+306+1083+200, 306+1083+577+457, 200+1083+577+947, 306+1083, 577+1083, 200+1083,1083,  main= "Heart versus kidney (hypomethylated)",  category = c("Human", "Chimp", "Rhesus macaque"), height=3000, width=3000, cex=2 , fill = pal[1:3], lty=1, cat.cex = 2, main.cex = 2)
## (polygon[GRID.polygon.33], polygon[GRID.polygon.34], polygon[GRID.polygon.35], polygon[GRID.polygon.36], polygon[GRID.polygon.37], polygon[GRID.polygon.38], text[GRID.text.39], text[GRID.text.40], text[GRID.text.41], text[GRID.text.42], text[GRID.text.43], text[GRID.text.44], text[GRID.text.45], text[GRID.text.46], text[GRID.text.47], text[GRID.text.48])
p1 <- ggdraw()+draw_image("../data/Hyper_heart_liver.svg")+draw_figure_label("11A.", size = 16, fontface = "bold")
p2 <- ggdraw()+draw_image("../data/Hypo_heart_liver.svg")+draw_figure_label("11B.", size = 16, fontface = "bold")

p3 <- ggdraw()+draw_image("../data/Hyper_heart_lung.svg")+draw_figure_label("11C.", size = 16, fontface = "bold")
p4 <- ggdraw()+draw_image("../data/Hypo_heart_lung.svg")+draw_figure_label("11D.", size = 16, fontface = "bold")

p5 <- ggdraw()+draw_image("../data/Hyper_heart_kidney.svg")+draw_figure_label("11E.", size = 16, fontface = "bold")
p6 <- ggdraw()+draw_image("../data/Hypo_heart_kidney.svg")+draw_figure_label("11F.", size = 16, fontface = "bold")

p7 <- ggdraw()+draw_image("../data/Hyper_liver_lung.svg")+draw_figure_label("11G.", size = 16, fontface = "bold")
p8 <- ggdraw()+draw_image("../data/Hypo_liver_lung.svg")+draw_figure_label("11H.", size = 16, fontface = "bold")

p9 <- ggdraw()+draw_image("../data/Hyper_liver_kidney.svg")+draw_figure_label("11I.", size = 16, fontface = "bold")
p10 <- ggdraw()+draw_image("../data/Hypo_liver_kidney.svg")+draw_figure_label("11J.", size = 16, fontface = "bold")

p11 <- ggdraw()+draw_image("../data/Hyper_lung_kidney.svg")+draw_figure_label("11K.", size = 16, fontface = "bold")
p12 <- ggdraw()+draw_image("../data/Hypo_lung_kidney.svg")+draw_figure_label("11L.", size = 16, fontface = "bold")


eight_plots <- plot_grid(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, ncol = 4)
plot_supp_fig <- plot_grid(eight_plots, ncol = 1, rel_heights=c(0.1, 1))


#save_plot("/Users/laurenblake/Dropbox/Quick_ref/Methylation/Hyper_hypo_pairwise.png", plot_supp_fig,
#          ncol = 4, # we're saving a grid plot of 2 columns
#          nrow = 3, # and 2 rows
          # each individual subplot should have an aspect ratio of 1.3
#          base_aspect_ratio = 0.75
#          )