File size: 2,541 Bytes
4b0a09a
e07fb1f
4b0a09a
8574486
 
3fb28d3
 
 
 
 
8574486
e1a4424
 
 
 
c513aeb
 
 
3fb28d3
 
 
 
25cd418
3fb28d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8574486
 
 
3fb28d3
8574486
f4d15bb
e1a4424
c513aeb
 
f4d15bb
3fb28d3
f4d15bb
8574486
c513aeb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fed1c09
c513aeb
685d6d8
c513aeb
 
 
 
 
 
685d6d8
c513aeb
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import streamlit as st
from predict_chromosome import predict_and_write


st.title("DeepLoop")
st.write("Looking for some example data?")
st.write(
    "http://hiview.case.edu/ssz20/tmp.HiCorr.ref/HiCorr_test_data/HiCorr_output.tar.gz"
)
st.write("Use hg19, HindIII, chr11, CPGZ and LoopDenoise for the Demo data")


#########
# INPUT #
#########
HiCorr_data_hf_repo = st.text_input(
    "HiCorr Data 🤗 Dataset", default="funlab/HiCorr_test_data"
)
training_set = st.selectbox("Select Training Set", ["CPGZ", "H9"], index=0)
depth = st.selectbox("Select Depth", ["LoopDenoise", "50M", "101K"], index=0)
# TODO Throw a warning that h9 only has LoopDenoise and 100M
chromosome = st.selectbox("Select Chromosome", ["chr11"])
prefix = "results"
genome = st.selectbox(
    "Reference Genome",
    [
        "hg19",
        "hg38",
        "mm10",
    ],
)
digestion_enzyme = st.selectbox(
    "Digestion Enzyme",
    [
        "HindIII",
        "Arima",
        # FIXME "microC_5kb_bin"
        "DPNII",
    ],
    index=0,
)
# TODO Add the other toggles
# small_matrix_size
# step_size
# max_dist
# dummy
# val_cols
# keep_zeros

# Load the model from hugging face
from huggingface_hub import from_pretrained_keras

model = from_pretrained_keras(f"funlab/DeepLoop-{training_set}-{depth}")

from huggingface_hub import snapshot_download

HiCorr_data = snapshot_download(HiCorr_data_hf_repo, repo_type="dataset")

anchors = snapshot_download(
    repo_id=f"funlab/{genome}_{digestion_enzyme}_anchor_bed", repo_type="dataset"
)

if st.button("Run Deeploop", type="primary"):
    denoised_anchor_to_anchor = None
    with st.spinner("Running the model"):
        denoised_anchor_to_anchor = predict_and_write(
            model,
            full_matrix_dir=HiCorr_data + f"/anchor_2_anchor.loop.{chromosome}",
            input_name=HiCorr_data + f"/anchor_2_anchor.loop.{chromosome}.p_val",
            outdir=prefix,
            anchor_dir=anchors,
            chromosome=chromosome,
            small_matrix_size=128,
            step_size=128,
            dummy=5,
            # max_dist,
            val_cols=["obs", "exp", "pval"],
            # keep_zeros,
        )

    st.success("Done!")

    # Print and list the files
    st.download_button(
        label="Download Denoised Results",
        data=os.path.join(prefix, chromosome + ".denoised.anchor.to.anchor"),
        file_name=chromosome + ".denoised.anchor.to.anchor",
        mime="text/csv",
    )
    st.dataframe(denoised_anchor_to_anchor)
    st.write(os.listdir(prefix))