How to use diff_tables method in dbt-osmosis

Best Python code snippet using dbt-osmosis_python

overlap.py

Source:overlap.py Github

copy

Full Screen

1import pandas as pd2import yaml3from glob import glob4from os import path5from functools import reduce6def get_tables_array(tool_selection, output_dir, comparison):7 tables = []8 for t in tool_selection:9 if t == "miso":10 # TODO: Implement11 pass12 if t == "rmats":13 diff_tables = glob(14 path.join(15 output_dir, "rmats", "results", comparison, "*.merged.w_coord.tsv"16 )17 )18 tables += diff_tables19 elif t == "whippet":20 diff_tables = glob(21 path.join(output_dir, "whippet", "delta", comparison, "*.diff.gz")22 )23 tables += diff_tables24 return tables25def format_cols(df_array, comparison):26 new_df_array = []27 condition_A, condition_B = comparison.split("_vs_")28 for df in df_array:29 if "bayes_factor" in df.columns:30 # TODO: Implement31 pass32 elif "FDR" in df.columns:33 rmats_cols = "coord event_type strand flank IncLevel1 IncLevel2 IncLevelDifference FDR".split()34 rmats_cols_rename = (35 "coord event_type strand rmats_flank rmats_psi_{} rmats_psi_{} rmats_dpsi rmats_fdr"36 .format(condition_A,condition_B).split()37 )38 df_subset = df[rmats_cols]39 df_subset.columns = rmats_cols_rename40 new_df_array.append(df_subset)41 elif "Probability" in df.columns:42 whippet_cols = "Coord Type Strand Psi_A Psi_B DeltaPsi Probability".split()43 whippet_cols_rename = (44 "coord whippet_type strand whippet_psi_{} whippet_psi_{} whippet_dpsi whippet_prob"45 .format(condition_A,condition_B).split()46 )47 df_subset = df[whippet_cols]48 df_subset.columns = whippet_cols_rename49 new_df_array.append(df_subset)50 return new_df_array51def significant_miso(x):52 if ((x.miso_dpsi >= 0.1) or (x.miso_dpsi <= -0.1)) and (x.miso_bf > 5):53 return True54 else:55 return False56 return None57def significant_rmats(x):58 if ((x.rmats_dpsi >= 0.1) or (x.rmats_dpsi <= -0.1)) and (x.rmats_fdr <= 0.1):59 return True60 else:61 return False62 return None63def significant_whippet(x):64 if ((x.whippet_dpsi >= 0.1) or (x.whippet_dpsi <= -0.1)) and (x.whippet_prob >= 0.9):65 return True66 else:67 return False68 return None69def assign_significance(tool_selection, dataframe):70 if "miso" in tool_selection:71 pass72 if "rmats" in tool_selection:73 dataframe["rmats_significant"] = dataframe.apply(74 lambda x: significant_rmats(x), axis=175 )76 if "whippet" in tool_selection:77 dataframe["whippet_significant"] = dataframe.apply(78 lambda x: significant_whippet(x), axis=179 )80 return dataframe81def assign_group(tool_selection, entry):82 group = ""83 for t in tool_selection:84 if t == "miso":85 if entry.miso_significant:86 group += "m"87 if t == "rmats":88 if entry.rmats_significant:89 group += "r"90 if t == "whippet":91 if entry.whippet_significant:92 group += "w"93 if group != "":94 entry["group"] = group95 elif group == "":96 entry["group"] = "none"97 return entry98tool_selection = snakemake.config["parameters"]["general"]["tools"]99output_dir = snakemake.config["locations"]["output_dir"]100comparison = snakemake.wildcards.comparison101tables = get_tables_array(tool_selection, output_dir, comparison)102df_array = [pd.read_csv(x, sep="\t", index_col=False) for x in tables]103df_array_formated = format_cols(df_array, comparison)104df_merged = reduce(lambda x,y: pd.merge(105 left=x, right=y, how="outer", on=["coord", "strand"]), df_array_formated106)107df_w_significance = assign_significance(tool_selection, df_merged)108df_w_group = (109 df_w_significance.apply(lambda x: assign_group(tool_selection, x), axis=1)110 .drop_duplicates()111)...

Full Screen

Full Screen

solution_1.py

Source:solution_1.py Github

copy

Full Screen

1import sys2def print_diff_table(n, values):3 diff_tables = [values]4 while len(diff_tables[-1]) > 1:5 diff_tables.append([])6 for i in range(len(diff_tables[-2]) - 1):7 diff_tables[-1].append(diff_tables[-2][i + 1] - diff_tables[-2][i])8 for i in range(len(diff_tables)):9 print("\t".join(map(str, diff_tables[i])))10 print()11def main():12 n = int(sys.stdin.readline().strip())13 v = list(map(int, sys.stdin.readline().strip().split()))14 print_diff_table(n, v)15if __name__ == '__main__':...

Full Screen

Full Screen

solution_2.py

Source:solution_2.py Github

copy

Full Screen

1import sys2def print_diff_table(n, values):3 diff_tables = [values]4 while len(diff_tables[-1]) > 1:5 diff_tables.append([])6 for i in range(len(diff_tables[-2]) - 1):7 diff_tables[-1].append(diff_tables[-2][i + 1] - diff_tables[-2][i])8 for i in range(len(diff_tables)):9 print("\t".join(map(str, diff_tables[i])))10 print()11def main():12 n = int(sys.stdin.readline().strip())13 v = list(map(int, sys.stdin.readline().strip().split()))14 print_diff_table(n, v)15if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run dbt-osmosis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful