简介
Dash Bio 是一个用于在Python中构建生物信息学和药物开发应用程序的开源工具包。许多Dash Bio 组件都建立在 JavaScript 库之上,这些库在生物信息学应用程序开发人员中已经很流行。
Plotly 团队对这些JavaScript 小部件进行了重新设计,以便 python 开发人员可以访问它们。
安装
win + R, cmd
pip install dash_bio #这里我安装的版本为 0.4.8
功能1. alignment
import dash
import dash_bio
import dash_html_components #.Div用于包裹元素
style = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
app = dash.Dash(__name__, external_stylesheets = style)
data = open("KSSK.fasta", "r").read()
app.layout = dash_html_components.Div([
dash_bio.AlignmentChart(id = "my_alignemnt",
data = data),
dash_html_components.Div(id = 'alignment-Viewer-output')
])
@app.callback(
dash.dependencies.Output('alignment-Viewer-output', 'asd'),
[dash.dependencies.Input('my_alignemnt', 'dsa')])
def update_output(value):
if value is None:
return 'No data.'
return str(value)
if __name__ == '__main__':
app.run_server()
结果展示
Dash.png一些修饰
1. Color Scales
dash_bio.AlignmentChart(id = "my_alignemnt",
data = data,
colorscale = 'buried', # 包括:buried、cinema、clustal、clustal2、helix、hydrophobicity、lesk、mae、nucleotide、purine、strand、taylor、turn、zappo
conservationcolorscale = 'rgb' ) #包括:hex、rgb、rgba
2. Show or Hide Barplots
dash_bio.AlignmentChart(id = "my_alignemnt",
data = data,
showconservation = False,
showgap = False)
3. Tile Size (调整每个细胞的宽度)
dash_bio.AlignmentChart(id = "my_alignemnt",
data = data,
tilewidth = 50)
4. Consensus Sequence (是否展示最后一行consensus)
dash_bio.AlignmentChart(id = "my_alignemnt",
data = data,
showconsensus = False)
5. 更详细的解释
help(dash_bio.AlignmentChart)
网友评论