<jupyter_start><jupyter_text>All Sites<jupyter_code>point=alt.OverlayMarkDef(filled=False, fill='white', strokeWidth=2)

def plot_lab(df=None, metric='cov'):
    d = df.copy()
        
    plot = alt.Chart(
        d
    ).mark_bar(
#         point=True,
        size=10,
#         opacity=0.3
    ).encode(
        y=alt.Y("c:N", title=None, axis=alt.Axis(labelAngle=0, tickCount=10), scale=alt.Scale(padding=1), sort=unique_c),
        x=alt.X("v:Q", title=None, scale=alt.Scale(zero=True, domain=[-3,3], padding=2, nice=False, clamp=True)),
        # color=alt.Color("siteid:N", scale=alt.Scale(domain=sites, range=site_colors)),
        color=alt.Color("g:N", scale=alt.Scale(domain=unique_g, range=colors), title='Category'),
    ).properties(
        width=150,
        height=250
    )

    plot = plot.facet(
        column=alt.Column("siteid:N", header=alt.Header(title=None), sort=sites)
    ).resolve_scale(color='shared')

    plot = plot.properties(
        title={
            "text": [
                f"Coefficient"
            ],
            "dx": 120,
            "subtitle": [
                'Lab values are standarized by SD',
                get_visualization_subtitle(data_release=data_release, with_num_sites=False)
            ],
            "subtitleColor": "gray",
        }
    )

    return plot

plot = plot_lab(df=df)

# plot = alt.vconcat(*(
#     plot_lab(df=df, lab=lab) for lab in unique_sites
# ), spacing=30)

plot = apply_theme(
    plot,
    axis_y_title_font_size=16,
    title_anchor='start',
    legend_orient='bottom',
    legend_title_orient='left',
    axis_label_font_size=14,
    header_label_font_size=16,
    point_size=100
)

plot<jupyter_output><empty_output><jupyter_text>Final Meta<jupyter_code>def plot_lab(df=None, metric='cov'):
    d = df.copy()
    d = d[d.siteid == 'META']
    print(unique_c)
    
    plot = alt.Chart(
        d
    ).mark_point(
        #point=True,
        size=120,
        filled=True,
        opacity=1
    ).encode(
        y=alt.Y("c:N", title=None, axis=alt.Axis(labelAngle=0, tickCount=10, grid=True), scale=alt.Scale(padding=1), sort=unique_c),
        x=alt.X("v:Q", title="Hazard Ratio", scale=alt.Scale(zero=True, domain=[0,3.6], padding=0, nice=False, clamp=True)),
        # color=alt.Color("siteid:N", scale=alt.Scale(domain=sites, range=site_colors)),
        color=alt.Color("g:N", scale=alt.Scale(domain=unique_g, range=colors), title='Category',legend=None),
    ).properties(
        width=550,
        height=400
    )
    line = alt.Chart(pd.DataFrame({'x': [1]})).mark_rule().encode(x='x', strokeWidth=alt.value(1), strokeDash=alt.value([2, 2]))
    tick = plot.mark_errorbar(
        opacity=0.7 #, color='black',
        #color=alt.Color("g:N", scale=alt.Scale(domain=unique_g, range=colors), title='Category')
    ).encode(
        y=alt.Y("c:N", sort=unique_c),
        x=alt.X("ci_l:Q", title="Hazard Ratio"),
        x2=alt.X2("ci_u:Q"),
        stroke=alt.value('black'),
        strokeWidth=alt.value(1)
    )
    plot = (line+tick+plot)
    #plot = plot.facet(
    #     column=alt.Column("siteid:N", header=alt.Header(title=None), sort=sites)
    #).resolve_scale(color='shared')

    #plot = plot.properties(
     #   title={
     #       "text": [
      #          f"Meta-Analysis Of Coefficient"
      #      ],
      #      "dx": 120,
      #      "subtitle": [
      #          'Lab values are standarized by SD'#,
       #         #get_visualization_subtitle(data_release=data_release, with_num_sites=False)
       #     ],
       #     "subtitleColor": "gray",
       # }
    #)

    return plot

plot = plot_lab(df=df)

# plot = alt.vconcat(*(
#     plot_lab(df=df, lab=lab) for lab in unique_sites
# ), spacing=30)

plot = apply_theme(
    plot,
    axis_y_title_font_size=16,
    title_anchor='start',
    #legend_orient='bottom',
    #legend_title_orient='top',
    axis_label_font_size=14,
    header_label_font_size=16,
    point_size=100
)

plot.display()
save(plot,join("..", "result", "final-beta-std-mice-meta.png"), scalefactor=8.0)<jupyter_output><empty_output><jupyter_text>Final country<jupyter_code>def plot_beta(df=None, metric='cov', country=None):
    d = df.copy()
    d = d[d.siteid == country]
    
    plot = alt.Chart(
        d
    ).mark_point(
#         point=True,
        size=120,
        filled=True,
        opacity=1
#         opacity=0.3
    ).encode(
        y=alt.Y("c:N", title=None, axis=alt.Axis(labelAngle=0, tickCount=10, grid=True), scale=alt.Scale(padding=1), sort=unique_c),
        x=alt.X("v:Q", title="Hazard Ratio", scale=alt.Scale(zero=True, domain=[0,4.6], padding=0, nice=False, clamp=True)),
        # color=alt.Color("siteid:N", scale=alt.Scale(domain=sites, range=site_colors)),
        color=alt.Color("g:N", scale=alt.Scale(domain=unique_g, range=colors), title='Category', legend=None),
    ).properties(
        width=750,
        height=550
    )
    line = alt.Chart(pd.DataFrame({'x': [1]})).mark_rule().encode(x='x', strokeWidth=alt.value(1), strokeDash=alt.value([2, 2]))

    tick = plot.mark_errorbar(
        opacity=0.7 #, color='black'
    ).encode(
        y=alt.Y("c:N", sort=unique_c),
        x=alt.X("ci_l:Q", title="Hazard Ratio"),
        x2=alt.X2("ci_u:Q"),
        stroke=alt.value('black'),
        strokeWidth=alt.value(1)
    )
    plot = (line+tick+plot)

#     plot = plot.facet(
#         column=alt.Column("siteid:N", header=alt.Header(title=None), sort=sites)
#     ).resolve_scale(color='shared')

    plot = plot.properties(
        title={
            "text": [
                country.replace("META-","")
            ],
            "dx": 160,
            #"subtitle": [
            #    'Lab values are standarized by SD'
            #],
            #"subtitleColor": "gray",
        }
    )

    return plot

countrylist1 = ["META-USA", "META-FRANCE"]
countrylist2 = ["META-GERMANY", "META-SPAIN"]


plot1 = alt.hconcat(*(
    plot_beta(df=df, country=country) for country in countrylist1
), spacing=30).resolve_scale(color='independent')


plot2 = alt.hconcat(*(
    plot_beta(df=df, country=country) for country in countrylist2
), spacing=30).resolve_scale(color='independent')


plot=alt.vconcat(plot1, plot2)
#plot=plot1

plot = apply_theme(
    plot,
    axis_y_title_font_size=16,
    title_anchor='start',
    legend_orient='bottom',
    legend_title_orient='left',
    axis_label_font_size=14,
    header_label_font_size=16,
    point_size=100
)


plot.display()

save(plot,join("..", "result", "final-beta-std-mice-country.png"), scalefactor=8.0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16909311495298757, 'fraction_numerical': 0.01986654534425235, 'mean_word_length': 2.927933293627159, 'pattern_counts': {'":': 12, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '11846', 'license': 'MIT', 'n_tokens_mistral': 2460, 'n_tokens_neox': 2351, 'n_words': 342, 'path': 'notebooks/2.1.waves.15.04_corr_std_mice.ipynb', 'repo_name': 'covidclinical/visualization-notebooks', 'size': '6594'}