loosolab / TF-COMB

Transcription Factor Co-Occurrence using Market Basket analysis
https://tf-comb.readthedocs.io
MIT License
10 stars 1 forks source link

How to get all TF-TF pairs' location #48

Open hcph opened 1 year ago

hcph commented 1 year ago

I want to know all the targets of TF-TF pairs and to construct an integrated regulatory network. I am new in python, and I find the protocol only tell us how to get the location of one TF pair. Could you please help me to get all pairs locations? Whether you can help, thank you very much for build such wonderful tool to analysis co-occur TFs.

hcph commented 1 year ago

I want to know all the targets of TF-TF pairs and to construct an integrated regulatory network. I am new in python, and I find the protocol only tell us how to get the location of one TF pair. Could you please help me to get all pairs locations? Whether you can help, thank you very much for build such wonderful tool to analysis co-occur TFs.

I successfully achieve it by the following commands: i = 0 while i < 167: TF1, TF2 = C.rules.iloc[i, [1,2]] pairs = C.get_pair_locations((TF1, TF2)) pairs.write_bed(str(i)+".bed", fmt="bedpe") i += 1

msbentsen commented 1 year ago

Hi @hcph ,

Great that you figured it out. For reference to other people as well, here is a full solution using the test data:

from tfcomb import CombObj

C = CombObj()
C.TFBS_from_motifs(regions="../data/GM12878_hg38_chr4_ATAC_peaks.bed",
                   motifs="../data/HOCOMOCOv11_HUMAN_motifs.txt",
                   genome="../data/hg38_chr4.fa.gz",
                   threads=4)

C.market_basket(threads=4)

for i in range(10):
    TF1, TF2 = C.rules.iloc[i, [0,1]]
    pairs = C.get_pair_locations((TF1, TF2))
    pairs.write_bed(f"{TF1}_{TF2}_sites.bedpe", fmt="bedpe") 

This will create files called <TF1>_<TF2>_sites.bedpe for the top 10 co-occurring TF pairs.