-
Notifications
You must be signed in to change notification settings - Fork 0
Empty Marker Plots #87
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
Conversation
lusSTR/workflows/strs.smk
Outdated
| system = os.name | ||
| if system == "nt": | ||
| shell("md logs\\{dt}\\Input\\") | ||
| shell('copy "{log}" logs\\{dt}\\') | ||
| shell("copy config.yaml logs\\{dt}\\") | ||
| new_file = input_name.replace("/", "\\") | ||
| if os.path.isdir(input_name): | ||
| shell('xcopy "{new_file}" logs\\{dt}\\Input') | ||
| else: | ||
| shell('copy "{new_file}" logs\\{dt}\\Input\\') | ||
| else: | ||
| shell("cp '{input_name}' logs/{dt}/input/") | ||
| shell("cp config.yaml logs/{dt}/") | ||
| shell("mkdir -p logs/{dt}/input/") | ||
| shell("cp '{log}' logs/{dt}/") | ||
| if os.path.isdir(input_name): | ||
| shell("cp '{input_name}'/*.* logs/{dt}/input/") | ||
| else: | ||
| shell("cp '{input_name}' logs/{dt}/input/") | ||
| shell("cp config.yaml logs/{dt}/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@standage I've added this to account for the different code required for a Mac/linux vs. windows os... is this kosher or not a good strategy to deal with it? This is the only difference between the Mac and windows version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each of these shell commands has equivalents in pathlib. Let me see if I can replicate it...
from shutil import copy
input_name = Path(input_name)
dtdir = Path("logs") / dt
logdir = dtdir / "input"
logdir.mkdir(parents=True, exist_ok=True)
copy(log, logdir / log)
if input_name.is_dir():
for path in input_name.glob("*.*"):
copy(path, logdir / path.name)
else:
copy(input_name, logdir / input_name.name
copy("config.yaml", dtdir / "config.yaml")That should work cross-platform.
|
|
||
| selected = option_menu( | ||
| menu_title=None, | ||
| options=["Home", "STRs", "SNPs", "How to Use", "Contact"], | ||
| icons=["house", "gear", "gear-fill", "book", "envelope"], | ||
| menu_icon="cast", | ||
| default_index=0, | ||
| orientation="horizontal", | ||
| ) | ||
| tab1, tab2, tab3, tab4, tab5 = st.tabs(["Home", "STRs", "SNPs", "How To Use", "Contact"]) | ||
|
|
||
| if selected == "Home": | ||
| with tab1: | ||
| show_home_page() | ||
|
|
||
| elif selected == "STRs": | ||
| with tab2: | ||
| show_STR_page() | ||
|
|
||
| elif selected == "SNPs": | ||
| with tab3: | ||
| show_SNP_page() | ||
|
|
||
| elif selected == "How to Use": | ||
| with tab4: | ||
| show_how_to_use_page() | ||
|
|
||
| elif selected == "Contact": | ||
| with tab5: | ||
| show_contact_page() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More changes to account for compatibility with Windows (the streamlit_option_menu package didn't work on Windows).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, more concise.
standage
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok overall, but I suggested a pure Python solution for copying the logs that should work across platforms.
|
|
||
| selected = option_menu( | ||
| menu_title=None, | ||
| options=["Home", "STRs", "SNPs", "How to Use", "Contact"], | ||
| icons=["house", "gear", "gear-fill", "book", "envelope"], | ||
| menu_icon="cast", | ||
| default_index=0, | ||
| orientation="horizontal", | ||
| ) | ||
| tab1, tab2, tab3, tab4, tab5 = st.tabs(["Home", "STRs", "SNPs", "How To Use", "Contact"]) | ||
|
|
||
| if selected == "Home": | ||
| with tab1: | ||
| show_home_page() | ||
|
|
||
| elif selected == "STRs": | ||
| with tab2: | ||
| show_STR_page() | ||
|
|
||
| elif selected == "SNPs": | ||
| with tab3: | ||
| show_SNP_page() | ||
|
|
||
| elif selected == "How to Use": | ||
| with tab4: | ||
| show_how_to_use_page() | ||
|
|
||
| elif selected == "Contact": | ||
| with tab5: | ||
| show_contact_page() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, more concise.
| sample_df = np.where( | ||
| sample_df["Locus"] == "AMELOGENIN", | ||
| np.where(sample_df["CE_Allele"] == "X", 0, 1), | ||
| sample_df["CE_Allele"], | ||
| ) | ||
| #sample_df = np.where( | ||
| # sample_df["Locus"] == "AMELOGENIN", | ||
| # np.where(sample_df["CE_Allele"] == "X", "0.0", "1.0"), | ||
| # sample_df["CE_Allele"], | ||
| #) | ||
| for i, row in sample_df.iterrows(): | ||
| if row["Locus"] == "AMELOGENIN": | ||
| sample_df.loc[i, "CE_Allele"] = 0 if row.CE_Allele == "X" else 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's figure out what to do with the commented out code before we merge.
lusSTR/workflows/strs.smk
Outdated
| system = os.name | ||
| if system == "nt": | ||
| shell("md logs\\{dt}\\Input\\") | ||
| shell('copy "{log}" logs\\{dt}\\') | ||
| shell("copy config.yaml logs\\{dt}\\") | ||
| new_file = input_name.replace("/", "\\") | ||
| if os.path.isdir(input_name): | ||
| shell('xcopy "{new_file}" logs\\{dt}\\Input') | ||
| else: | ||
| shell('copy "{new_file}" logs\\{dt}\\Input\\') | ||
| else: | ||
| shell("cp '{input_name}' logs/{dt}/input/") | ||
| shell("cp config.yaml logs/{dt}/") | ||
| shell("mkdir -p logs/{dt}/input/") | ||
| shell("cp '{log}' logs/{dt}/") | ||
| if os.path.isdir(input_name): | ||
| shell("cp '{input_name}'/*.* logs/{dt}/input/") | ||
| else: | ||
| shell("cp '{input_name}' logs/{dt}/input/") | ||
| shell("cp config.yaml logs/{dt}/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each of these shell commands has equivalents in pathlib. Let me see if I can replicate it...
from shutil import copy
input_name = Path(input_name)
dtdir = Path("logs") / dt
logdir = dtdir / "input"
logdir.mkdir(parents=True, exist_ok=True)
copy(log, logdir / log)
if input_name.is_dir():
for path in input_name.glob("*.*"):
copy(path, logdir / path.name)
else:
copy(input_name, logdir / input_name.name
copy("config.yaml", dtdir / "config.yaml")That should work cross-platform.
lusSTR/wrappers/filter.py
Outdated
| # if df[df["SampleID"] == sample_id].empty: | ||
| # print(f"{sample_id} does not have any reads passing filter. Skipping to next sample.") | ||
| # else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here.
Creating empty plots for samples with no reads above the detection threshold at any marker. This is to be able to evaluate negative samples (negative controls, RBs, etc.).