bestMotifPerTF: Take best motif per TF

Description Usage Arguments Value Examples

Description

Given a table of motif enrichments in PCs (as created with getKMerTFEnrichment), selects only the best motif per TF (treating each PC and direction separately) where TFs have more than one motif. Thus, different motifs could be selected for different PCs/directions.

Usage

1
bestMotifPerTF(motifEnrichments)

Arguments

motifEnrichments

data.frame as made by getKMerTFEnrichment, and merged with cisbp$TFTable, such that it has column names including c("Motif_ID", "direction","p","TF_Name","PC"))

Value

Returns a filtered version of motifEnrichments with a new column "sameTF" containing all the Motif_IDs that represented the same TF, but had a lower enrichment

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
kmerMat = inputKMerFreqs(sprintf("kMerFiles/%s.freq.gz",sampleDesc$id), IDs = sampleDesc$id)
myPCA = doKMerPCA(kmerMat, nPCs = "jackstraw")
treatmentPCs = findDistinguishingPCs(myPCA$rotation[,1:myPCA$nPCs], sampleDesc[c("id","treated")])
tfEnrichmentsPBM = getKMerTFEnrichment(myPCA$rotation[,1:myPCA$nPCs], cisbp$binaryPBMZScores);
tfEnrichmentsPBM = tfEnrichmentsPBM[order(tfEnrichmentsPBM$p),]
tfEnrichmentsPBM = merge(tfEnrichmentsPBM2, cisbp$TFTable[c("Motif_ID","TF_Name")], by="Motif_ID") # add TF names
tfEnrichmentsPBM = preferDirect(tfEnrichmentsPBM, cisbp$TFTable)
tfEnrichmentsPBM$Bon.P = tfEnrichmentsPBM$p + log(nrow(tfEnrichmentsPBM)) +  log(3000) #approximate Bonferroni MHT correction; multiply by 3000 for n_max
tfEnrichmentsPBM = tfEnrichmentsPBM[tfEnrichmentsPBM$Bon.P < log(0.01),] # cutoff of P<0.01
tfEnrichmentsPBM_NR = dropSimilarMotifs(tfEnrichmentsPBM, cisbp$similarMotifs);
tfEnrichmentsPBM_NR_onePerTF = bestMotifPerTF(tfEnrichmentsPBM_NR);

Carldeboer/BrockmanR documentation built on May 31, 2019, 2:19 p.m.