### Install PyMSAviz Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Installs the pymsaviz library using pip. This is typically the first step before using the library. ```Python # %pip install pymsaviz ``` -------------------------------- ### Create MSA Visualization with Markers and Text Annotations Source: https://github.com/moshi4/pymsaviz/blob/main/example/api_example_run.ipynb This example demonstrates advanced customization by specifying a start and end range for the visualization, adding custom markers at specific positions (including calculated ones based on consensus identity), and adding text annotations to highlight regions. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, start=1, end=180, wrap_length=60, show_consensus=True) # Extract MSA positions less than 50% consensus identity pos_ident_less_than_50 = [] ident_list = mv._get_consensus_identity_list() for pos, ident in enumerate(ident_list, 1): if ident <= 50: pos_ident_less_than_50.append(pos) # Add markers mv.add_markers([1]) mv.add_markers([10, 20], color="orange", marker="o") mv.add_markers([30, (40, 50), 55], color="green", marker="+ ") mv.add_markers(pos_ident_less_than_50, marker="x", color="blue") # Add text annotations mv.add_text_annotation((76, 102), "Gap Region", text_color="red", range_color="red") mv.add_text_annotation((112, 123), "Gap Region", text_color="green", range_color="green") mv.savefig("api_example03.png") ``` -------------------------------- ### Create MSA Visualization with Default Settings Source: https://github.com/moshi4/pymsaviz/blob/main/example/api_example_run.ipynb This example demonstrates the basic usage of PyMSAvis to create an MSA visualization. It loads a test MSA file and saves the visualization to a PNG file with default settings. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("HIGD2A.fa") mv = MsaViz(msa_file, wrap_length=60, show_count=True) mv.savefig("api_example01.png") ``` -------------------------------- ### pymsaviz Example 1: Identity Color Scheme Source: https://github.com/moshi4/pymsaviz/blob/main/docs/cli-docs/pymsaviz.md An example command for pymsaviz that visualizes an MSA file using the 'Identity' color scheme and saves the output as a PNG image. ```bash pymsaviz -i ./example/HIGD2A.fa -o cli_example01.png --color_scheme Identity ``` -------------------------------- ### Install pyMSAviz via PyPI Source: https://github.com/moshi4/pymsaviz/blob/main/docs/index.md Installs the pyMSAviz package using pip, the Python package installer. This is the standard method for installing Python libraries from the Python Package Index (PyPI). ```bash pip install pymsaviz ``` -------------------------------- ### pymsaviz Example 2: Wrapped MSA with Consensus Source: https://github.com/moshi4/pymsaviz/blob/main/docs/cli-docs/pymsaviz.md This example demonstrates using pymsaviz with specific options: wrapping the MSA at 80 characters, applying the 'Taylor' color scheme, and showing the consensus sequence and character counts. ```bash pymsaviz -i ./example/MRGPRG.fa -o cli_example02.png --wrap_length 80 \ --color_scheme Taylor --show_consensus --show_count ``` -------------------------------- ### PyMSAviz CLI Example 1: Basic Visualization Source: https://github.com/moshi4/pymsaviz/blob/main/README.md Generates a basic MSA visualization using the 'Identity' color scheme. This example demonstrates the core functionality of converting an MSA file to a visual representation. ```bash pymsaviz -i ./example/HIGD2A.fa -o cli_example01.png --color_scheme Identity ``` -------------------------------- ### pymsaviz Example 3: Specific Range and Grid Source: https://github.com/moshi4/pymsaviz/blob/main/docs/cli-docs/pymsaviz.md An example showcasing pymsaviz for visualizing a specific range (100-160) of an MSA, using the 'Flower' color scheme, displaying a grid, the consensus sequence, and a custom consensus color. ```bash pymsaviz -i ./example/MRGPRG.fa -o cli_example03.png --start 100 --end 160 \ --color_scheme Flower --show_grid --show_consensus --consensus_color tomato ``` -------------------------------- ### Install pyMSAviz via Conda Source: https://github.com/moshi4/pymsaviz/blob/main/docs/index.md Installs the pyMSAviz package using Conda, a popular package and environment management system. This command installs from both the conda-forge and bioconda channels. ```bash conda install -c conda-forge -c bioconda pymsaviz ``` -------------------------------- ### Create MSA Visualization with Custom Color Scheme and Grid Source: https://github.com/moshi4/pymsaviz/blob/main/example/api_example_run.ipynb This example shows how to customize the MSA visualization by applying a specific color scheme ('Taylor'), setting the wrap length, and enabling the display of the consensus sequence and grid lines. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, color_scheme="Taylor", wrap_length=80, show_grid=True, show_consensus=True) mv.savefig("api_example02.png") ``` -------------------------------- ### PyMSAviz CLI Example 2: Wrapped and Consensus Visualization Source: https://github.com/moshi4/pymsaviz/blob/main/README.md Creates an MSA visualization with wrapped sequences and displays the consensus sequence and character counts. This example utilizes the 'Taylor' color scheme and specific display options for enhanced readability. ```bash pymsaviz -i ./example/MRGPRG.fa -o cli_example02.png --wrap_length 80 \ --color_scheme Taylor --show_consensus --show_count ``` -------------------------------- ### Simple MSA Visualization Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Creates an MsaViz instance from an MSA file and plots the figure using the plotfig method. This is a basic example of visualizing an MSA. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("HIGD2A.fa") mv = MsaViz(msa_file) fig = mv.plotfig() # If save figure, use savefig method [e.g. mv.savefig("result.png")] ``` -------------------------------- ### PyMSAviz CLI Example 3: Specific Range and Grid Visualization Source: https://github.com/moshi4/pymsaviz/blob/main/README.md Generates an MSA visualization for a specific range of sequences, including a grid and custom consensus bar color. This example showcases fine-grained control over the visualization output. ```bash pymsaviz -i ./example/MRGPRG.fa -o cli_example03.png --start 100 --end 160 \ --color_scheme Flower --show_grid --show_consensus --consensus_color tomato ``` -------------------------------- ### MSA Visualization with Grid (Marker List Reference) Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Initializes an MsaViz object with a limited end range and displays a grid. This example also includes a comment referencing the matplotlib marker API. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, end=60, show_grid=True) ``` -------------------------------- ### Visualize MSA with Default Settings Source: https://github.com/moshi4/pymsaviz/blob/main/README.md This example demonstrates the basic usage of the MsaViz class to visualize a Multiple Sequence Alignment (MSA) file. It loads a test MSA file, creates an MsaViz object with a specified wrap length and option to show sequence counts, and saves the visualization to a PNG file. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("HIGD2A.fa") mv = MsaViz(msa_file, wrap_length=60, show_count=True) mv.savefig("api_example01.png") ``` -------------------------------- ### Visualize MSA with Custom Color Scheme and Consensus Source: https://github.com/moshi4/pymsaviz/blob/main/README.md This example shows how to customize the MSA visualization by applying a specific color scheme ('Taylor'), setting the wrap length, and displaying the consensus sequence. It loads a different test MSA file and saves the customized visualization. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, color_scheme="Taylor", wrap_length=80, show_grid=True, show_consensus=True) mv.savefig("api_example02.png") ``` -------------------------------- ### Annotate MSA with Markers and Text Source: https://github.com/moshi4/pymsaviz/blob/main/README.md This example demonstrates advanced customization of MSA visualization by adding markers and text annotations. It calculates positions with less than 50% consensus identity and marks them, adds custom markers with specific colors and styles, and annotates specific regions with text. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, end=180, wrap_length=60, show_consensus=True) # Extract MSA positions less than 50% consensus identity pos_ident_less_than_50 = [] ident_list = mv._get_consensus_identity_list() for pos, ident in enumerate(ident_list, 1): if ident <= 50: pos_ident_less_than_50.append(pos) # Add markers mv.add_markers([1]) mv.add_markers([10, 20], color="orange", marker="o") mv.add_markers([30, (40, 50), 55], color="green", marker="+") mv.add_markers(pos_ident_less_than_50, marker="x", color="blue") # Add text annotations mv.add_text_annotation((76, 102), "Gap Region", text_color="red", range_color="red") mv.add_text_annotation((112, 123), "Gap Region", text_color="green", range_color="green") mv.savefig("api_example03.png") ``` -------------------------------- ### Apply Color Schemes to MSA Visualization in pyMSAviz Source: https://github.com/moshi4/pymsaviz/blob/main/docs/color_schemes.ipynb This example demonstrates how to apply different color schemes to a Multiple Sequence Alignment (MSA) visualization using pyMSAviz. It iterates through available color schemes, creates an MsaViz object for a specified MSA region, and plots the result with the scheme name as the title. ```python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") for color_scheme in MsaViz.available_color_schemes(): mv = MsaViz(msa_file, start=100, end=160, color_scheme=color_scheme, show_label=False) fig = mv.plotfig() fig.suptitle(f"Color Scheme = {color_scheme}", x=0.5, y=1.15, va="bottom", size=15) ``` -------------------------------- ### MSA Visualization with Range Limit and Character Hiding Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Limits the MSA visualization to a specific start and end range and hides the display of individual sequence characters. It also shows the consensus sequence with a specified color. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, start=100, end=160, show_seq_char=False, show_consensus=True, consensus_color="tomato") fig = mv.plotfig() ``` -------------------------------- ### Change Plot Parameters Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb This example shows how to modify various plot parameters for an MSA visualization using the `set_plot_params` method. It customizes tick intervals, unit sizes, grid color, and identity color. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, start=100 ,end=140, show_grid=True, show_count=True, color_scheme="Identity") mv.set_plot_params(ticks_interval=5, x_unit_size=0.20, grid_color="black", identity_color="tomato") fig = mv.plotfig() ``` -------------------------------- ### pymsaviz Help and Options Source: https://github.com/moshi4/pymsaviz/blob/main/docs/cli-docs/pymsaviz.md Demonstrates how to access the help message for pymsaviz, which lists all available command-line options for customizing MSA visualizations, including input/output files, color schemes, and display settings. ```bash pymsaviz --help ``` -------------------------------- ### PyMSAviz Help and Basic Usage Source: https://github.com/moshi4/pymsaviz/blob/main/README.md Displays the help message for the pymsaviz CLI tool, outlining its purpose and available options. The basic usage involves specifying an input MSA file and an output visualization file. ```bash pymsaviz --help usage: pymsaviz [options] -i msa.fa -o msa_viz.png MSA(Multiple Sequence Alignment) visualization CLI tool optional arguments: -i I, --infile I Input MSA file -o O, --outfile O Output MSA visualization file (*.png|*.jpg|*.svg|*.pdf) --format MSA file format (Default: 'fasta') --color_scheme Color scheme (Default: 'Zappo') --start Start position of MSA visualization (Default: 1) --end End position of MSA visualization (Default: 'MSA Length') --wrap_length Wrap length (Default: None) --wrap_space_size Space size between wrap MSA plot area (Default: 3.0) --label_type Label type ('id'[default]|'description') --show_grid Show grid (Default: OFF) --show_count Show seq char count without gap on right side (Default: OFF) --show_consensus Show consensus sequence (Default: OFF) --consensus_color Consensus identity bar color (Default: '#1f77b4') --consensus_size Consensus identity bar height size (Default: 2.0) --sort Sort MSA order by NJ tree constructed from MSA distance matrix (Default: OFF) --dpi Figure DPI (Default: 300) -v, --version Print version information -h, --help Show this help message and exit ``` -------------------------------- ### Basic pymsaviz Usage Source: https://github.com/moshi4/pymsaviz/blob/main/docs/cli-docs/pymsaviz.md This snippet shows the fundamental command structure for using the pymsaviz CLI. It requires an input MSA file and specifies an output file for the visualization. ```bash pymsaviz -i [MSA file] -o [MSA visualization file] ``` -------------------------------- ### Styled MSA Visualization with Color Scheme Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Visualizes an MSA with a specified wrap length and color scheme ('Flower'). It also shows the count of sequences. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("HIGD2A.fa") mv = MsaViz(msa_file, wrap_length=60, color_scheme="Flower", show_count=True) fig = mv.plotfig() ``` -------------------------------- ### Add Markers with Different Colors Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb This snippet demonstrates how to add various marker types to an MSA visualization, cycling through a predefined list of colors. It utilizes the `add_markers` method of the MsaViz object. ```Python markers = [".", ",", "o", "v", "^", "<", ">", "1", "2", "3", "4", "8", "s", "p", "*", "h", "H", "+", "x", "D", "d", "|", "_"] colors = ["red", "blue", "green", "chocolate", "magenta"] for idx, marker in enumerate(markers, 1): color = colors[idx % len(colors)] mv.add_markers([idx * 2], marker=marker, color=color, size=8) fig = mv.plotfig() ``` -------------------------------- ### MSA Visualization with Grid and Consensus Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Displays an MSA with a grid and shows the consensus sequence along with an identity bar. This helps in analyzing sequence conservation. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, wrap_length=60, show_grid=True, show_consensus=True) fig = mv.plotfig() ``` -------------------------------- ### List Available Color Schemes in pyMSAviz Source: https://github.com/moshi4/pymsaviz/blob/main/docs/color_schemes.ipynb This snippet shows how to retrieve a list of all color schemes supported by the pyMSAviz library. It imports the MsaViz class and calls the static method `available_color_schemes()`. ```python from pymsaviz import MsaViz print(MsaViz.available_color_schemes()) ``` -------------------------------- ### Color Block MSA Display Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb This snippet illustrates how to display a color-blocked MSA with specific configurations. It sets the color scheme to 'Clustal', hides sequence characters, shows counts, sorts the sequences, and displays consensus with a grey color. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, color_scheme="Clustal", show_seq_char=False, show_count=True, sort=True, show_consensus=True, consensus_color="grey") mv.set_plot_params(ticks_interval=50, x_unit_size=0.04, show_consensus_char=False) fig = mv.plotfig() ``` -------------------------------- ### Add Markers and Text Annotations to MSA Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Adds markers and text annotations to the MSA visualization. This includes adding markers at specific positions, with custom colors and styles, and annotating regions like 'Gap Region'. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, start=1, end=180, wrap_length=60, show_consensus=True) # Extract MSA positions less than 50% consensus identity pos_ident_less_than_50 = [] ident_list = mv._get_consensus_identity_list() for pos, ident in enumerate(ident_list, 1): if ident <= 50: pos_ident_less_than_50.append(pos) # Add markers mv.add_markers([1]) mv.add_markers([10, 20], color="orange", marker="o") mv.add_markers([30, (40, 50), 55], color="green", marker="+ ") mv.add_markers(pos_ident_less_than_50, marker="x", color="blue") # Add text annotations mv.add_text_annotation((76, 102), "Gap Region", text_color="red", range_color="red") mv.add_text_annotation((112, 123), "Gap Region", text_color="green", range_color="green") fig = mv.plotfig() ``` -------------------------------- ### Custom MSA Color Scheme Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Applies a user-defined custom color scheme to the MSA visualization using the set_custom_color_scheme method. This allows for specific coloring of amino acids. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, start=100, end=160) mv.set_custom_color_scheme({"A": "red", "P": "skyblue", "C": "lime", "H": "orange", "L": "pink"}) fig = mv.plotfig() ``` -------------------------------- ### Highlight MSA by Identity Threshold Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Highlights positions in the MSA based on a consensus identity threshold. This method helps identify regions with varying degrees of conservation. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, start=100, end=160, show_consensus=True) # Only highlight 0 - 80 [%] consensus identity positions mv.set_highlight_pos_by_ident_thr(min_thr=0, max_thr=80) fig = mv.plotfig() ``` -------------------------------- ### Highlight MSA Positions Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Highlights specific positions or ranges within the MSA using the set_highlight_pos method. This is useful for drawing attention to particular regions of interest. ```Python from pymsaviz import MsaViz, get_msa_testdata msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, wrap_length=60) mv.set_highlight_pos([10, 20, 30, (40, 120), (150, 200), 220, 270]) fig = mv.plotfig() ``` -------------------------------- ### Custom MSA Color Function Source: https://github.com/moshi4/pymsaviz/blob/main/docs/getting_started.ipynb Sets a user-defined function to determine the color of each sequence character based on its position and the MSA content. This provides fine-grained control over coloring. ```Python from pymsaviz import MsaViz, get_msa_testdata from Bio.Align import MultipleSeqAlignment msa_file = get_msa_testdata("MRGPRG.fa") mv = MsaViz(msa_file, start=100, end=160, show_grid=True) def custom_color_func( row_pos: int, col_pos: int, seq_char: str, msa: MultipleSeqAlignment ): # Note: Both `row_pos` and `col_pos` are 0-index starts if col_pos < 115 and seq_char != "-": return "salmon" if 115 <= col_pos < 130: if seq_char in ("A", "V", "P"): return "skyblue" else: return "lightyellow" if 130 <= col_pos < 145: if 1 <= row_pos <= 4: return "lime" else: return "white" # Use default color setting in other column (145 <= col_pos < 160) return None mv.set_custom_color_func(custom_color_func) fig = mv.plotfig() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.