Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def composite(df, sameGenderMZ, sameGenderDZ, size=(16, 24)):
"""Embed both absdiff figures and heritability figures.
"""
fig = plt.figure(1, size)
ax1a = plt.subplot2grid((6, 4), (0, 0), rowspan=2, colspan=1)
ax2a = plt.subplot2grid((6, 4), (0, 1), rowspan=2, colspan=1)
ax3a = plt.subplot2grid((6, 4), (0, 2), rowspan=2, colspan=1)
ax4a = plt.subplot2grid((6, 4), (0, 3), rowspan=2, colspan=1)
ax1b = plt.subplot2grid((6, 4), (2, 0), rowspan=2, colspan=2)
ax2b = plt.subplot2grid((6, 4), (2, 2), rowspan=2, colspan=2)
ax3b = plt.subplot2grid((6, 4), (4, 0), rowspan=2, colspan=2)
ax4b = plt.subplot2grid((6, 4), (4, 2), rowspan=2, colspan=2)
# Telomeres
telomeres = extract_trait(df, "Sample name", "telomeres.Length")
mzTelomeres = extract_twin_values(sameGenderMZ, telomeres)
dzTelomeres = extract_twin_values(sameGenderDZ, telomeres)
plot_paired_values(ax1b, mzTelomeres, dzTelomeres, label="Telomere length")
plot_abs_diff(ax1a, mzTelomeres, dzTelomeres, label="Telomere length")
# CCNX
def composite(df, sameGenderMZ, sameGenderDZ, size=(16, 24)):
"""Embed both absdiff figures and heritability figures.
"""
fig = plt.figure(1, size)
ax1a = plt.subplot2grid((6, 4), (0, 0), rowspan=2, colspan=1)
ax2a = plt.subplot2grid((6, 4), (0, 1), rowspan=2, colspan=1)
ax3a = plt.subplot2grid((6, 4), (0, 2), rowspan=2, colspan=1)
ax4a = plt.subplot2grid((6, 4), (0, 3), rowspan=2, colspan=1)
ax1b = plt.subplot2grid((6, 4), (2, 0), rowspan=2, colspan=2)
ax2b = plt.subplot2grid((6, 4), (2, 2), rowspan=2, colspan=2)
ax3b = plt.subplot2grid((6, 4), (4, 0), rowspan=2, colspan=2)
ax4b = plt.subplot2grid((6, 4), (4, 2), rowspan=2, colspan=2)
# Telomeres
telomeres = extract_trait(df, "Sample name", "telomeres.Length")
mzTelomeres = extract_twin_values(sameGenderMZ, telomeres)
dzTelomeres = extract_twin_values(sameGenderDZ, telomeres)
plot_paired_values(ax1b, mzTelomeres, dzTelomeres, label="Telomere length")
plot_abs_diff(ax1a, mzTelomeres, dzTelomeres, label="Telomere length")
# CCNX
CCNX = extract_trait(df, "Sample name", "ccn.chrX")
mzCCNX = extract_twin_values(sameGenderMZ, CCNX, gender="Female")
dzCCNX = extract_twin_values(sameGenderDZ, CCNX, gender="Female")
dzCCNX = filter_low_values(dzCCNX, 1.75)
def composite_qc(df_orig, size=(16, 12)):
""" Plot composite QC figures
"""
df = df_orig.rename(columns={"hli_calc_age_sample_taken": "Age",
"hli_calc_gender": "Gender",
"eth7_max": "Ethnicity",
"MeanCoverage": "Mean coverage",
"Chemistry": "Sequencing chemistry",
"Release Client": "Cohort",
})
fig = plt.figure(1, size)
ax1 = plt.subplot2grid((2, 7), (0, 0), rowspan=1, colspan=2)
ax2 = plt.subplot2grid((2, 7), (0, 2), rowspan=1, colspan=2)
ax3 = plt.subplot2grid((2, 7), (0, 4), rowspan=1, colspan=3)
ax4 = plt.subplot2grid((2, 7), (1, 0), rowspan=1, colspan=2)
ax5 = plt.subplot2grid((2, 7), (1, 2), rowspan=1, colspan=2)
ax6 = plt.subplot2grid((2, 7), (1, 4), rowspan=1, colspan=3)
sns.distplot(df["Age"].dropna(), kde=False, ax=ax1)
sns.countplot(x="Gender", data=df, ax=ax2)
sns.countplot(x="Ethnicity", data=df, ax=ax3,
order = df['Ethnicity'].value_counts().index)
sns.distplot(df["Mean coverage"].dropna(), kde=False, ax=ax4)
ax4.set_xlim(0, 100)
sns.countplot(x="Sequencing chemistry", data=df, ax=ax5)
sns.countplot(x="Cohort", data=df, ax=ax6,
order = df['Cohort'].value_counts().index)
# Anonymize the cohorts
cohorts = ax6.get_xticklabels()
newCohorts = []
def composite_ccn(df, size=(12, 8)):
""" Plot composite ccn figure
"""
fig = plt.figure(1, size)
ax1 = plt.subplot2grid((2, 2), (0, 0))
ax2 = plt.subplot2grid((2, 2), (0, 1))
ax3 = plt.subplot2grid((2, 2), (1, 0))
ax4 = plt.subplot2grid((2, 2), (1, 1))
chemistry = ["V1", "V2", "V2.5", float("nan")]
colors = sns.color_palette("Set2", 8)
color_map = dict(zip(chemistry, colors))
mf = df[df["hli_calc_gender"] == "Male"]
age_label = "Chronological age (yr)"
ax1.scatter(mf["hli_calc_age_sample_taken"], mf["ccn.chrX"],
s=10, marker='.',
color='lightslategray')
ax1.set_ylim(0.8, 1.1)
plot_fit_line(ax1, mf["hli_calc_age_sample_taken"], mf["ccn.chrX"])
ax1.set_ylabel("ChrX copy number")
ax1.set_title("ChrX copy number in Male")
df = df_orig.rename(columns={"hli_calc_age_sample_taken": "Age",
"hli_calc_gender": "Gender",
"eth7_max": "Ethnicity",
"MeanCoverage": "Mean coverage",
"Chemistry": "Sequencing chemistry",
"Release Client": "Cohort",
})
fig = plt.figure(1, size)
ax1 = plt.subplot2grid((2, 7), (0, 0), rowspan=1, colspan=2)
ax2 = plt.subplot2grid((2, 7), (0, 2), rowspan=1, colspan=2)
ax3 = plt.subplot2grid((2, 7), (0, 4), rowspan=1, colspan=3)
ax4 = plt.subplot2grid((2, 7), (1, 0), rowspan=1, colspan=2)
ax5 = plt.subplot2grid((2, 7), (1, 2), rowspan=1, colspan=2)
ax6 = plt.subplot2grid((2, 7), (1, 4), rowspan=1, colspan=3)
sns.distplot(df["Age"].dropna(), kde=False, ax=ax1)
sns.countplot(x="Gender", data=df, ax=ax2)
sns.countplot(x="Ethnicity", data=df, ax=ax3,
order = df['Ethnicity'].value_counts().index)
sns.distplot(df["Mean coverage"].dropna(), kde=False, ax=ax4)
ax4.set_xlim(0, 100)
sns.countplot(x="Sequencing chemistry", data=df, ax=ax5)
sns.countplot(x="Cohort", data=df, ax=ax6,
order = df['Cohort'].value_counts().index)
# Anonymize the cohorts
cohorts = ax6.get_xticklabels()
newCohorts = []
for i, c in enumerate(cohorts):
if c.get_text() == "Spector":
c = "TwinsUK"
def composite_qc(df_orig, size=(16, 12)):
""" Plot composite QC figures
"""
df = df_orig.rename(columns={"hli_calc_age_sample_taken": "Age",
"hli_calc_gender": "Gender",
"eth7_max": "Ethnicity",
"MeanCoverage": "Mean coverage",
"Chemistry": "Sequencing chemistry",
"Release Client": "Cohort",
})
fig = plt.figure(1, size)
ax1 = plt.subplot2grid((2, 7), (0, 0), rowspan=1, colspan=2)
ax2 = plt.subplot2grid((2, 7), (0, 2), rowspan=1, colspan=2)
ax3 = plt.subplot2grid((2, 7), (0, 4), rowspan=1, colspan=3)
ax4 = plt.subplot2grid((2, 7), (1, 0), rowspan=1, colspan=2)
ax5 = plt.subplot2grid((2, 7), (1, 2), rowspan=1, colspan=2)
ax6 = plt.subplot2grid((2, 7), (1, 4), rowspan=1, colspan=3)
sns.distplot(df["Age"].dropna(), kde=False, ax=ax1)
sns.countplot(x="Gender", data=df, ax=ax2)
sns.countplot(x="Ethnicity", data=df, ax=ax3,
order = df['Ethnicity'].value_counts().index)
sns.distplot(df["Mean coverage"].dropna(), kde=False, ax=ax4)
ax4.set_xlim(0, 100)
sns.countplot(x="Sequencing chemistry", data=df, ax=ax5)
sns.countplot(x="Cohort", data=df, ax=ax6,
order = df['Cohort'].value_counts().index)
# Anonymize the cohorts
cohorts = ax6.get_xticklabels()
def composite_qc(df_orig, size=(16, 12)):
""" Plot composite QC figures
"""
df = df_orig.rename(columns={"hli_calc_age_sample_taken": "Age",
"hli_calc_gender": "Gender",
"eth7_max": "Ethnicity",
"MeanCoverage": "Mean coverage",
"Chemistry": "Sequencing chemistry",
"Release Client": "Cohort",
})
fig = plt.figure(1, size)
ax1 = plt.subplot2grid((2, 7), (0, 0), rowspan=1, colspan=2)
ax2 = plt.subplot2grid((2, 7), (0, 2), rowspan=1, colspan=2)
ax3 = plt.subplot2grid((2, 7), (0, 4), rowspan=1, colspan=3)
ax4 = plt.subplot2grid((2, 7), (1, 0), rowspan=1, colspan=2)
ax5 = plt.subplot2grid((2, 7), (1, 2), rowspan=1, colspan=2)
ax6 = plt.subplot2grid((2, 7), (1, 4), rowspan=1, colspan=3)
sns.distplot(df["Age"].dropna(), kde=False, ax=ax1)
sns.countplot(x="Gender", data=df, ax=ax2)
sns.countplot(x="Ethnicity", data=df, ax=ax3,
order = df['Ethnicity'].value_counts().index)
sns.distplot(df["Mean coverage"].dropna(), kde=False, ax=ax4)
ax4.set_xlim(0, 100)
sns.countplot(x="Sequencing chemistry", data=df, ax=ax5)
sns.countplot(x="Cohort", data=df, ax=ax6,
order = df['Cohort'].value_counts().index)
# Anonymize the cohorts
"""
df = df_orig.rename(columns={"hli_calc_age_sample_taken": "Age",
"hli_calc_gender": "Gender",
"eth7_max": "Ethnicity",
"MeanCoverage": "Mean coverage",
"Chemistry": "Sequencing chemistry",
"Release Client": "Cohort",
})
fig = plt.figure(1, size)
ax1 = plt.subplot2grid((2, 7), (0, 0), rowspan=1, colspan=2)
ax2 = plt.subplot2grid((2, 7), (0, 2), rowspan=1, colspan=2)
ax3 = plt.subplot2grid((2, 7), (0, 4), rowspan=1, colspan=3)
ax4 = plt.subplot2grid((2, 7), (1, 0), rowspan=1, colspan=2)
ax5 = plt.subplot2grid((2, 7), (1, 2), rowspan=1, colspan=2)
ax6 = plt.subplot2grid((2, 7), (1, 4), rowspan=1, colspan=3)
sns.distplot(df["Age"].dropna(), kde=False, ax=ax1)
sns.countplot(x="Gender", data=df, ax=ax2)
sns.countplot(x="Ethnicity", data=df, ax=ax3,
order = df['Ethnicity'].value_counts().index)
sns.distplot(df["Mean coverage"].dropna(), kde=False, ax=ax4)
ax4.set_xlim(0, 100)
sns.countplot(x="Sequencing chemistry", data=df, ax=ax5)
sns.countplot(x="Cohort", data=df, ax=ax6,
order = df['Cohort'].value_counts().index)
# Anonymize the cohorts
cohorts = ax6.get_xticklabels()
newCohorts = []
for i, c in enumerate(cohorts):
if c.get_text() == "Spector":