Skip to content

Merge DiffBind and Uropa outputs with the attached functions #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tovahmarkowitz opened this issue Nov 25, 2024 · 0 comments
Closed
Assignees

Comments

@tovahmarkowitz
Copy link
Collaborator

prepDiffBind <- function(DiffBindFile) {
  inDiffBindData <- read.delim(DiffBindFile)
  DiffBindData <- inDiffBindData[order(inDiffBindData$seqnames,inDiffBindData$start),]
  DiffBindData$peak_id <- paste0("Peak",1:nrow(DiffBindData))
  return(DiffBindData)
}

loadAndMerge <- function(DiffBindFile, UropaFile) {
  DiffBindData <- prepDiffBind(DiffBindFile)
  UropaData <- read.delim(UropaFile)
  MergedData <- merge(DiffBindData,UropaData)

  #which(MergedData$end != MergedData$peak_end)
  #names(MergedData)
  #[1] "peak_id"           "seqnames"          "start"             "end"              
  #[5] "width"             "strand"            "Conc"              "Conc_D5pos4"      
  #[9] "Conc_D5neg4"       "Fold"              "p.value"           "FDR"              
  #[13] "Called1"           "Called2"           "peak_chr"          "peak_start"       
  #[17] "peak_end"          "peak_score"        "peak_strand"       "feature"          
  #[21] "feat_start"        "feat_end"          "feat_strand"       "feat_anchor"      
  #[25] "distance"          "relative_location" "feat_ovl_peak"     "peak_ovl_feat"    
  #[29] "gene_id"           "gene_name"         "gene_type"         "name"

  MergedData2 <- MergedData[order(MergedData$FDR,decreasing = F),
                            c(2:5,1,8:10,12,21:26,29:32)]
  return(MergedData2)
}

FilterMerged <- function(MergedData2,FDRcutoff=0.05,FoldCutoff=0) {
  MergedDataFDR <- MergedData2[which(MergedData2$FDR < FDRcutoff),]
  MergedDataFiltered <- MergedDataFDR[which((MergedDataFDR$Fold > FoldCutoff) | 
                                            (MergedDataFDR$Fold) < -(FoldCutoff)),]
  return(MergedDataFiltered)
}
@rroutsong rroutsong self-assigned this Dec 9, 2024
@rroutsong rroutsong added the post refactor issues to be undertaken after refactor label Mar 4, 2025
@rroutsong rroutsong removed the post refactor issues to be undertaken after refactor label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants