scallops.visualize.crosstalk.pairwise_channel_scatter_plot
- scallops.visualize.crosstalk.pairwise_channel_scatter_plot(bases, plot_func=None, q=None, col_wrap=3, intensity_column='intensity', **plot_args)
Pairwise channel intensity scatter plot.
This function creates a scatter plot for pairwise combinations of channels in the provided DataArray.
- Parameters:
bases (DataArray | DataFrame) – The input array containing intensity values for different channels across samples and time points.
plot_func (Callable[[ndarray, ndarray, int, int, Axes, Any], None]) – Function to plot x-y scatter plot that accepts channel i values, channel j values, i, j, axis, and plot keyword arguments (e.g. markersize).
q (tuple[float, ...]) – Tuple of lower and upper quantiles to include for Li and Speed fit. If None, do not perform fit.
col_wrap (int) – Wrap the plot at this width, so that the plot spans multiple rows.
intensity_column (str) – The name of the column in bases containing the intensity when bases is data frame.
plot_args – Additional arguments to pass to the plot function (e.g. markersize)
- Returns:
The figure and axes object with the plot drawn onto it.
- Examples:
Generate a pairwise channel scatter plot
import xarray as xr import matplotlib.pyplot as plt from scallops.visualize import pairwise_channel_scatter_plot # Create a sample DataArray channels = ["ChannelA", "ChannelT", "ChannelG", "ChannelC"] data = xr.DataArray( np.random.rand(100, 10, len(channels)), dims=("read", "t", "c"), coords={"c": channels}, ) # Generate a pairwise channel scatter plot fig, axes = pairwise_channel_scatter_plot( data, q=(0.1, 0.9), col_wrap=2 ) # Show the plot plt.show()
Generate a pairwise channel scatter plot with colors by their base calls
import xarray as xr import matplotlib.pyplot as plt import matplotlib.patches as mpatches from scallops.visualize import pairwise_channel_scatter_plot # Create a sample DataArray channels = ["ChannelA", "ChannelT", "ChannelG", "ChannelC"] data = xr.DataArray( np.random.rand(100, 10, len(channels)), dims=("read", "t", "c"), coords={"c": channels}, ) bases = ["G", "T", "A", "C"] base_calls = pd.Series(np.random.choice(bases, size=100)) base_colors = {"G": "green", "T": "red", "A": "magenta", "C": "cyan"} def plot_func(x, y, i, j, ax, **plot_args): ax.scatter( x, y, c=base_calls.apply(lambda x: base_colors[x]), **plot_args ) fig, axes = pairwise_channel_scatter_plot( data.isel(t=0), plot_func=plot_func ) patches = [ mpatches.Patch(color=color, label=label) for label, color in base_colors.items() ] plt.legend(handles=patches) plt.show()
- Return type:
tuple[Figure, Axes]