adding model postprocessing steps
Browse files- backend/PvDeepSetNet/src/DeepSets/DeepSets_pipeline.py +11 -28
- backend/PvDeepSetNet/src/DeepSets/Model_result.py +12 -459
- backend/PvDeepSetNet/src/DeepSets/Post_model_computation.py +123 -0
- backend/PvDeepSetNet/src/DeepSets/Preprocess.py +6 -4
- backend/PvDeepSetNet/src/DeepSets/PvRecNet_plots.py +122 -0
- backend/PvDeepSetNet/src/DeepSets/__init__.py +4 -2
- backend/PvDeepSetNet/src/DeepSets/__pycache__/DeepSets_pipeline.cpython-310.pyc +0 -0
- backend/PvDeepSetNet/src/DeepSets/__pycache__/Model_result.cpython-310.pyc +0 -0
- backend/PvDeepSetNet/src/DeepSets/__pycache__/Post_model_computation.cpython-310.pyc +0 -0
- backend/PvDeepSetNet/src/DeepSets/__pycache__/Preprocess.cpython-310.pyc +0 -0
- backend/PvDeepSetNet/src/DeepSets/__pycache__/PvRecNet_plots.cpython-310.pyc +0 -0
- backend/PvDeepSetNet/src/DeepSets/__pycache__/__init__.cpython-310.pyc +0 -0
- backend/PvDeepSetNet/tests/temp.ipynb +1713 -3
backend/PvDeepSetNet/src/DeepSets/DeepSets_pipeline.py
CHANGED
|
@@ -2,7 +2,7 @@ import json
|
|
| 2 |
import torch
|
| 3 |
from sklearn.metrics import r2_score
|
| 4 |
from .Preprocess import DataPreprocessor
|
| 5 |
-
from .Model_result import
|
| 6 |
|
| 7 |
|
| 8 |
|
|
@@ -21,39 +21,22 @@ def run_prediction(data, mode='prediction'):
|
|
| 21 |
|
| 22 |
if mode == 'prediction':
|
| 23 |
req_column = ['patient_id', 'episode', 'marker', 'allele', 'country']
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
meta_df = data[['sample_id_paired', 'patient_id', 'true_episode', 'prior_C', 'prior_L', 'prior_I']].drop_duplicates().reset_index(drop=True)
|
| 32 |
tensors = DataPreprocessor.build_deepsets_tensors(df=data, mode=mode)
|
| 33 |
loaded_data = DataPreprocessor.load_tensor(tensors, mode)
|
| 34 |
|
| 35 |
-
return
|
| 36 |
pair_id=tensors['pair_id'],
|
| 37 |
data_loader = loaded_data,
|
| 38 |
basic_summary=True)
|
| 39 |
-
|
| 40 |
-
# req_column = ['pair_id', 'episode', 'marker', 'allele', 'country', 'prior_C', 'prior_L', 'prior_I', 'post_C', 'post_L', 'post_I']
|
| 41 |
-
|
| 42 |
-
# data = DataPreprocessor.calculate_MOIs(data)
|
| 43 |
-
# meta_df = data[['pair_id', 'patient_id', 'episode']].drop_duplicates().reset_index(drop=True)
|
| 44 |
-
|
| 45 |
-
# tensors = DataPreprocessor.build_deepsets_tensors(df=data, mode=mode)
|
| 46 |
-
# loaded_data = DataPreprocessor.load_tensor(tensors, mode)
|
| 47 |
-
|
| 48 |
-
# return PvDeepSet_model.run_evaluation(meta_df=meta_df,
|
| 49 |
-
# pair_id=tensors['pair_id'],
|
| 50 |
-
# data_loader=loaded_data,
|
| 51 |
-
# probability_plot = True,
|
| 52 |
-
# metrics=True,
|
| 53 |
-
# confusion_matrix=True,
|
| 54 |
-
# basic_summary=True)
|
| 55 |
-
# else:
|
| 56 |
-
# return 'incorrect mode'
|
| 57 |
|
| 58 |
|
| 59 |
|
|
|
|
| 2 |
import torch
|
| 3 |
from sklearn.metrics import r2_score
|
| 4 |
from .Preprocess import DataPreprocessor
|
| 5 |
+
from .Model_result import PvDeepSet_Model
|
| 6 |
|
| 7 |
|
| 8 |
|
|
|
|
| 21 |
|
| 22 |
if mode == 'prediction':
|
| 23 |
req_column = ['patient_id', 'episode', 'marker', 'allele', 'country']
|
| 24 |
+
data, meta_df = (
|
| 25 |
+
data
|
| 26 |
+
.pipe(DataPreprocessor.removing_single_episode_patients)
|
| 27 |
+
.pipe(DataPreprocessor.calculate_population_Allele_frequencies, population='country')
|
| 28 |
+
.pipe(DataPreprocessor.calculate_MOIs)
|
| 29 |
+
.pipe(DataPreprocessor.paired_episode_assigner)
|
| 30 |
+
)
|
| 31 |
+
# meta_df = data[['sample_id_paired', 'patient_id', 'true_episode', 'prior_C', 'prior_L', 'prior_I']].drop_duplicates().reset_index(drop=True)
|
| 32 |
tensors = DataPreprocessor.build_deepsets_tensors(df=data, mode=mode)
|
| 33 |
loaded_data = DataPreprocessor.load_tensor(tensors, mode)
|
| 34 |
|
| 35 |
+
return PvDeepSet_Model.run_prediction(meta_df=meta_df,
|
| 36 |
pair_id=tensors['pair_id'],
|
| 37 |
data_loader = loaded_data,
|
| 38 |
basic_summary=True)
|
| 39 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
|
backend/PvDeepSetNet/src/DeepSets/Model_result.py
CHANGED
|
@@ -7,13 +7,14 @@ import seaborn as sns
|
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
import plotly.express as px
|
| 9 |
from sklearn.metrics import r2_score
|
| 10 |
-
from DeepSets import PvDeepSets
|
| 11 |
from sklearn.metrics import classification_report, confusion_matrix
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
-
class
|
| 17 |
@staticmethod
|
| 18 |
def load_model_state():
|
| 19 |
#-------------------------------------#
|
|
@@ -43,106 +44,7 @@ class PvDeepSet_model:
|
|
| 43 |
model.load_state_dict(torch.load(file_path, weights_only=True, map_location=device))
|
| 44 |
|
| 45 |
return device, model
|
| 46 |
-
@staticmethod
|
| 47 |
-
def result_post_processing(results_df, calc_NU_post = True, approx_joint = True):
|
| 48 |
-
"""
|
| 49 |
-
result_df: PvDeepSet predicted results
|
| 50 |
-
calc_NU_post: calculate non uniform posterior (refine the posterior if the priors were not default)
|
| 51 |
-
approx_joint: approximate marginal probabilities from perwise results
|
| 52 |
-
"""
|
| 53 |
-
if calc_NU_post:
|
| 54 |
-
|
| 55 |
-
# 1. Align column names for math operations
|
| 56 |
-
# We create a temporary copy to ensure we multiply the right classes
|
| 57 |
-
df_priors = results_df[['prior_C', 'prior_L', 'prior_I']].rename(columns={'prior_C': 'C', 'prior_L': 'L', 'prior_I': 'I'})
|
| 58 |
|
| 59 |
-
df_post_uni = results_df[['prob_C', 'prob_L', 'prob_I']].rename(columns={'prob_C': 'C', 'prob_L': 'L', 'prob_I': 'I'})
|
| 60 |
-
|
| 61 |
-
# 2. Numerator: Multiply P_uniform(s|y) * P(s)
|
| 62 |
-
# Pandas handles row-matching automatically by index
|
| 63 |
-
numerator = df_post_uni * df_priors
|
| 64 |
-
|
| 65 |
-
# 3. Denominator: Sum across the columns for each row (Normalization)
|
| 66 |
-
denominator = numerator.sum(axis=1)
|
| 67 |
-
|
| 68 |
-
# 4. Final Recovery: Divide numerator by denominator
|
| 69 |
-
# axis=0 ensures the division happens row by row
|
| 70 |
-
df_post_non_uniform = numerator.divide(denominator, axis=0)
|
| 71 |
-
|
| 72 |
-
df_post_non_uniform['C'] = df_post_non_uniform['C'].round(4)
|
| 73 |
-
df_post_non_uniform['L'] = df_post_non_uniform['L'].round(4)
|
| 74 |
-
df_post_non_uniform['I'] = df_post_non_uniform['I'].round(4)
|
| 75 |
-
|
| 76 |
-
results_df['prob_C'] = df_post_non_uniform['C'].values
|
| 77 |
-
results_df['prob_L'] = df_post_non_uniform['L'].values
|
| 78 |
-
results_df['prob_I'] = df_post_non_uniform['I'].values
|
| 79 |
-
return df_post_non_uniform
|
| 80 |
-
|
| 81 |
-
if approx_joint:
|
| 82 |
-
"""
|
| 83 |
-
Python implementation of the Pv3Rs approx-joint marginalization logic.
|
| 84 |
-
Assumes df contains: patient_id, episode_i, episode_j, post_C, post_L, post_I
|
| 85 |
-
"""
|
| 86 |
-
|
| 87 |
-
def assign_source_episodes(df):
|
| 88 |
-
df = df.sort_values(['patient_id', 'true_episode']).copy()
|
| 89 |
-
|
| 90 |
-
# We create a counter that resets for every new 'true_episode'
|
| 91 |
-
# This identifies if the row is comparing against the 1st, 2nd, or 3rd previous episode
|
| 92 |
-
df['pair_source'] = df.groupby(['patient_id', 'true_episode']).cumcount() + 1
|
| 93 |
-
return df.sort_values('pair_id')
|
| 94 |
-
|
| 95 |
-
df = assign_source_episodes(results_df)
|
| 96 |
-
|
| 97 |
-
results = []
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
for pid, group in df.groupby('patient_id'):
|
| 101 |
-
# Get unique episodes in chronological order
|
| 102 |
-
# Based on your data, episodes are 1, 2, 4, 5, 6...
|
| 103 |
-
episodes = sorted(group['true_episode'].unique())
|
| 104 |
-
n_epi = len(episodes)
|
| 105 |
-
|
| 106 |
-
# We start calculating from the first recurrence (index 1)
|
| 107 |
-
for idx in range(1, n_epi):
|
| 108 |
-
curr_epi = episodes[idx]
|
| 109 |
-
prev_epi = episodes[idx-1]
|
| 110 |
-
|
| 111 |
-
# --- CALCULATE C (Recrudescence) ---
|
| 112 |
-
# Rule: Only look at the immediate predecessor
|
| 113 |
-
c_row = group[(group['true_episode'] == curr_epi) & (group['pair_source'] == prev_epi)]
|
| 114 |
-
# If your data doesn't have 'pair_source', we look for the specific pair
|
| 115 |
-
# where j = curr_epi and i = prev_epi
|
| 116 |
-
C_prob = c_row['prob_C'].iloc[0] if not c_row.empty else 0.0
|
| 117 |
-
|
| 118 |
-
# --- CALCULATE L (Relapse) ---
|
| 119 |
-
# Rule: Max( L / (1-C) ) across all previous episodes, then scale by (1-C_total)
|
| 120 |
-
|
| 121 |
-
# Get all pairs where 'episode' is our current episode
|
| 122 |
-
all_prev_pairs = group[group['true_episode'] == curr_epi]
|
| 123 |
-
|
| 124 |
-
# Calculate the 'relapse share': L / (1 - C)
|
| 125 |
-
# Use small epsilon to avoid division by zero
|
| 126 |
-
shares = all_prev_pairs['prob_L'] / (1 - all_prev_pairs['prob_C'] + 1e-9)
|
| 127 |
-
max_share = shares.max()
|
| 128 |
-
|
| 129 |
-
L_prob = max_share * (1 - C_prob)
|
| 130 |
-
|
| 131 |
-
# --- CALCULATE I (Reinfection) ---
|
| 132 |
-
# Rule: The remainder
|
| 133 |
-
I_prob = 1 - (C_prob + L_prob)
|
| 134 |
-
|
| 135 |
-
results.append({
|
| 136 |
-
'patient_id': pid,
|
| 137 |
-
'episode': curr_epi,
|
| 138 |
-
'C_marg': C_prob,
|
| 139 |
-
'L_marg': L_prob,
|
| 140 |
-
'I_marg': I_prob
|
| 141 |
-
})
|
| 142 |
-
results_df = pd.DataFrame(results)
|
| 143 |
-
return results_df
|
| 144 |
-
|
| 145 |
-
|
| 146 |
|
| 147 |
@staticmethod
|
| 148 |
def get_model_results(model, dataloader, device, threshold=0.5, mode='prediction'):
|
|
@@ -177,80 +79,6 @@ class PvDeepSet_model:
|
|
| 177 |
|
| 178 |
return pred_stack
|
| 179 |
|
| 180 |
-
# @staticmethod
|
| 181 |
-
# def calculate_approx_marginals(df):
|
| 182 |
-
# """
|
| 183 |
-
# Python implementation of the Pv3Rs approx-joint marginalization logic.
|
| 184 |
-
# Assumes df contains: patient_id, episode_i, episode_j, post_C, post_L, post_I
|
| 185 |
-
# """
|
| 186 |
-
# # 1. Identify the unique episodes for this patient (sorted)
|
| 187 |
-
# # We assume 'episode' in your sample refers to the current episode (j)
|
| 188 |
-
# # and we need to identify the source episode (i).
|
| 189 |
-
# # For this example, let's derive i and j from your structure.
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
# def assign_source_episodes(df):
|
| 193 |
-
# df = df.sort_values(['patient_id', 'true_episode']).copy()
|
| 194 |
-
|
| 195 |
-
# # We create a counter that resets for every new 'true_episode'
|
| 196 |
-
# # This identifies if the row is comparing against the 1st, 2nd, or 3rd previous episode
|
| 197 |
-
# df['pair_source'] = df.groupby(['patient_id', 'true_episode']).cumcount() + 1
|
| 198 |
-
# return df.sort_values('pair_id')
|
| 199 |
-
|
| 200 |
-
# df = assign_source_episodes(df)
|
| 201 |
-
|
| 202 |
-
# results = []
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
# for pid, group in df.groupby('patient_id'):
|
| 206 |
-
# # Get unique episodes in chronological order
|
| 207 |
-
# # Based on your data, episodes are 1, 2, 4, 5, 6...
|
| 208 |
-
# episodes = sorted(group['true_episode'].unique())
|
| 209 |
-
# n_epi = len(episodes)
|
| 210 |
-
|
| 211 |
-
# # We start calculating from the first recurrence (index 1)
|
| 212 |
-
# for idx in range(1, n_epi):
|
| 213 |
-
# curr_epi = episodes[idx]
|
| 214 |
-
# prev_epi = episodes[idx-1]
|
| 215 |
-
|
| 216 |
-
# # --- CALCULATE C (Recrudescence) ---
|
| 217 |
-
# # Rule: Only look at the immediate predecessor
|
| 218 |
-
# c_row = group[(group['true_episode'] == curr_epi) & (group['pair_source'] == prev_epi)]
|
| 219 |
-
# # If your data doesn't have 'pair_source', we look for the specific pair
|
| 220 |
-
# # where j = curr_epi and i = prev_epi
|
| 221 |
-
# C_prob = c_row['prob_C'].iloc[0] if not c_row.empty else 0.0
|
| 222 |
-
|
| 223 |
-
# # --- CALCULATE L (Relapse) ---
|
| 224 |
-
# # Rule: Max( L / (1-C) ) across all previous episodes, then scale by (1-C_total)
|
| 225 |
-
|
| 226 |
-
# # Get all pairs where 'episode' is our current episode
|
| 227 |
-
# all_prev_pairs = group[group['true_episode'] == curr_epi]
|
| 228 |
-
|
| 229 |
-
# # Calculate the 'relapse share': L / (1 - C)
|
| 230 |
-
# # Use small epsilon to avoid division by zero
|
| 231 |
-
# shares = all_prev_pairs['prob_L'] / (1 - all_prev_pairs['prob_C'] + 1e-9)
|
| 232 |
-
# max_share = shares.max()
|
| 233 |
-
|
| 234 |
-
# L_prob = max_share * (1 - C_prob)
|
| 235 |
-
|
| 236 |
-
# # --- CALCULATE I (Reinfection) ---
|
| 237 |
-
# # Rule: The remainder
|
| 238 |
-
# I_prob = 1 - (C_prob + L_prob)
|
| 239 |
-
|
| 240 |
-
# results.append({
|
| 241 |
-
# 'patient_id': pid,
|
| 242 |
-
# 'episode': curr_epi,
|
| 243 |
-
# 'C_marg': C_prob,
|
| 244 |
-
# 'L_marg': L_prob,
|
| 245 |
-
# 'I_marg': I_prob
|
| 246 |
-
# })
|
| 247 |
-
# marg_result = pd.DataFrame(results)
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
# return marg_result
|
| 253 |
-
|
| 254 |
@staticmethod
|
| 255 |
def run_prediction(meta_df,
|
| 256 |
pair_id,
|
|
@@ -258,11 +86,11 @@ class PvDeepSet_model:
|
|
| 258 |
basic_summary=True):
|
| 259 |
|
| 260 |
# 1. call a function that load saved model state
|
| 261 |
-
device, model =
|
| 262 |
|
| 263 |
# 2. get model prediction result
|
| 264 |
# Shape: [N, 3] -> Column 0: C, Column 1: L, Column 2: I
|
| 265 |
-
predicted_probs =
|
| 266 |
|
| 267 |
# 3. Merge IDs with Probabilities
|
| 268 |
# Create a DataFrame from the results
|
|
@@ -275,18 +103,8 @@ class PvDeepSet_model:
|
|
| 275 |
results_df.insert(0, 'pair_id', pair_id)
|
| 276 |
|
| 277 |
results_df = results_df.merge(meta_df, left_on='pair_id', right_on='sample_id_paired', how='inner')
|
| 278 |
-
|
| 279 |
-
results_df =
|
| 280 |
-
# results_df = PvDeepSet_model.result_post_processing(unique_result, calc_NU_post=False, approx_joint=True)
|
| 281 |
-
|
| 282 |
-
return results_df
|
| 283 |
-
|
| 284 |
-
# get marginal probabilities
|
| 285 |
-
marginal_df = PvDeepSet_model.calculate_approx_marginals(results_df[['pair_id', 'patient_id', 'true_episode', 'prob_C', 'prob_L', 'prob_I']])
|
| 286 |
-
marginal_df['predicted_class'] = marginal_df.apply(classify_row, axis=1, cols=['C_marg', 'L_marg', 'I_marg'])
|
| 287 |
-
donut_plot = plot_donut_count(marginal_df)
|
| 288 |
-
marginal_df['patient_id_epi'] = marginal_df['patient_id'] + "_" + marginal_df['episode'].astype(int).astype('str')
|
| 289 |
-
probability_dist_plot = plot_probability_dist(marginal_df, cols=['patient_id_epi', 'C_marg', 'L_marg','I_marg','predicted_class'])
|
| 290 |
|
| 291 |
|
| 292 |
# 4. Hardclass Classification with Threshold Logic
|
|
@@ -305,282 +123,17 @@ class PvDeepSet_model:
|
|
| 305 |
# Apply the logic to create the new column
|
| 306 |
results_df['predicted_class'] = results_df.apply(classify_row, axis=1)
|
| 307 |
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
dist_df.columns = ['class', 'count']
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
# fig = px.bar(
|
| 315 |
-
# dist_df, x='class', y='count',
|
| 316 |
-
# color='class', title="Classification Distribution",
|
| 317 |
-
# template="plotly_white"
|
| 318 |
-
# )
|
| 319 |
-
def plot_donut_count(df):
|
| 320 |
-
# 1. Prepare the data
|
| 321 |
-
# Assuming 'df' is your processed dataframe from the previous step
|
| 322 |
-
counts_df = df['predicted_class'].value_counts().reset_index()
|
| 323 |
-
counts_df.columns = ['Class', 'Count']
|
| 324 |
-
map_rec = {'C':'C (Recrudescence)', 'L': 'L (Relapse)', 'I':'I (Reinfection)'}
|
| 325 |
-
|
| 326 |
-
counts_df['Class'] = counts_df['Class'].map(map_rec)
|
| 327 |
-
|
| 328 |
-
# 2. Create the Donut Chart
|
| 329 |
-
fig = px.pie(
|
| 330 |
-
counts_df,
|
| 331 |
-
values='Count',
|
| 332 |
-
names='Class',
|
| 333 |
-
hole=0.5, # This creates the "donut" effect
|
| 334 |
-
color='Class',
|
| 335 |
-
# Keeping colors consistent: Orange (C), Yellow (L), Teal (I)
|
| 336 |
-
color_discrete_map={
|
| 337 |
-
'C (Recrudescence)': '#ff4d00',
|
| 338 |
-
'L (Relapse)': '#e6b400',
|
| 339 |
-
'I (Reinfection)': '#1fb3c4'
|
| 340 |
-
},
|
| 341 |
-
template="plotly_white"
|
| 342 |
-
)
|
| 343 |
-
|
| 344 |
-
# 3. Refine the layout to match your previous style
|
| 345 |
-
fig.update_layout(
|
| 346 |
-
margin=dict(l=20, r=20, t=60, b=20),
|
| 347 |
-
height=500,
|
| 348 |
-
paper_bgcolor='white',
|
| 349 |
-
# Horizontal legend at the top
|
| 350 |
-
legend=dict(
|
| 351 |
-
orientation="h",
|
| 352 |
-
yanchor="bottom",
|
| 353 |
-
y=1.05,
|
| 354 |
-
xanchor="center",
|
| 355 |
-
x=0.5,
|
| 356 |
-
title=None
|
| 357 |
-
)
|
| 358 |
-
)
|
| 359 |
-
|
| 360 |
-
# 4. Enhance the traces (labels and percentages)
|
| 361 |
-
fig.update_traces(
|
| 362 |
-
textposition='inside',
|
| 363 |
-
textinfo='percent+label', # Shows the Class name and %
|
| 364 |
-
marker=dict(line=dict(color='#FFFFFF', width=2)) # Adds a small white gap between segments
|
| 365 |
-
)
|
| 366 |
-
|
| 367 |
-
return fig
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
def plot_probability_dist(df, cols=['pair_id', 'prob_C', 'prob_L','prob_I','predicted_class']):
|
| 371 |
-
|
| 372 |
-
df = df.copy()
|
| 373 |
-
df = df[cols].drop_duplicates().reset_index(drop=True)
|
| 374 |
-
|
| 375 |
-
# Grouped and sorted blocks
|
| 376 |
-
df_C = df[df.predicted_class == 'C'].sort_values(cols[1], ascending=False).reset_index(drop=True)
|
| 377 |
-
df_L = df[df.predicted_class == 'L'].sort_values(cols[2], ascending=False).reset_index(drop=True)
|
| 378 |
-
df_I = df[df.predicted_class == 'I'].sort_values(cols[3], ascending=False).reset_index(drop=True)
|
| 379 |
-
|
| 380 |
-
df_sorted = pd.concat([df_C, df_L, df_I], ignore_index=True)
|
| 381 |
-
|
| 382 |
-
df_long = df_sorted.melt(
|
| 383 |
-
id_vars=cols[0],
|
| 384 |
-
value_vars=cols[1:4],
|
| 385 |
-
var_name='Probability_Type',
|
| 386 |
-
value_name='Probability'
|
| 387 |
-
)
|
| 388 |
-
|
| 389 |
-
fig = px.bar(
|
| 390 |
-
df_long,
|
| 391 |
-
x=cols[0],
|
| 392 |
-
y="Probability",
|
| 393 |
-
color="Probability_Type",
|
| 394 |
-
color_discrete_sequence=['#ff4d00', '#e6b400', '#1fb3c4'],
|
| 395 |
-
category_orders={cols[0]: df_sorted[cols[0]].tolist()},
|
| 396 |
-
template="plotly_white" # Sets white background and clean gridlines
|
| 397 |
-
)
|
| 398 |
-
|
| 399 |
-
fig.update_layout(
|
| 400 |
-
title=None,
|
| 401 |
-
margin=dict(l=50, r=20, t=60, b=50), # Adjusted for axis labels
|
| 402 |
-
height=500,
|
| 403 |
-
paper_bgcolor='white',
|
| 404 |
-
plot_bgcolor='white',
|
| 405 |
-
|
| 406 |
-
# Horizontal legend at the top
|
| 407 |
-
legend=dict(
|
| 408 |
-
orientation="h",
|
| 409 |
-
yanchor="bottom",
|
| 410 |
-
y=1.02,
|
| 411 |
-
xanchor="center",
|
| 412 |
-
x=0.5,
|
| 413 |
-
title=None
|
| 414 |
-
),
|
| 415 |
-
|
| 416 |
-
xaxis=dict(
|
| 417 |
-
title="Samples", # Restored the label
|
| 418 |
-
showticklabels=False, # Keeps specific IDs hidden for cleanliness
|
| 419 |
-
ticks="",
|
| 420 |
-
linecolor='black', # Adds a crisp base line
|
| 421 |
-
showgrid=False
|
| 422 |
-
),
|
| 423 |
-
|
| 424 |
-
yaxis=dict(
|
| 425 |
-
title="Probability",
|
| 426 |
-
range=[0, 1],
|
| 427 |
-
tickformat=".1f",
|
| 428 |
-
linecolor='black',
|
| 429 |
-
gridcolor='lightgrey' # Subtle grid for probability reference
|
| 430 |
-
),
|
| 431 |
-
|
| 432 |
-
bargap=0
|
| 433 |
-
)
|
| 434 |
-
|
| 435 |
-
return fig
|
| 436 |
|
| 437 |
-
donut_plot = plot_donut_count(results_df)
|
| 438 |
-
probability_dist_plot = plot_probability_dist(results_df)
|
| 439 |
-
|
| 440 |
-
# results_df = results_df.merge(meta_df, left_on='pair_id', right_on='sample_id_paired', how='inner')
|
| 441 |
-
|
| 442 |
-
# # get marginal probabilities
|
| 443 |
-
# marginal_df = PvDeepSet_model.calculate_approx_marginals(results_df[['pair_id', 'patient_id', 'true_episode', 'prob_C', 'prob_L', 'prob_I']])
|
| 444 |
-
# marginal_df['predicted_class'] = marginal_df.apply(classify_row, axis=1, cols=['C_marg', 'L_marg', 'I_marg'])
|
| 445 |
-
# donut_plot = plot_donut_count(marginal_df)
|
| 446 |
-
# marginal_df['patient_id_epi'] = marginal_df['patient_id'] + "_" + marginal_df['episode'].astype(int).astype('str')
|
| 447 |
-
# probability_dist_plot = plot_probability_dist(marginal_df, cols=['patient_id_epi', 'C_marg', 'L_marg','I_marg','predicted_class'])
|
| 448 |
|
| 449 |
columns = ['pair_id', 'patient_id', 'true_episode', 'prob_C', 'prob_L', 'prob_I', 'predicted_class']
|
| 450 |
results = {
|
| 451 |
-
'results_table':
|
| 452 |
'donut_plot': donut_plot,
|
| 453 |
'distribution_plot': probability_dist_plot
|
| 454 |
}
|
| 455 |
|
| 456 |
return results
|
| 457 |
-
|
| 458 |
-
def run_evaluation(meta_df,
|
| 459 |
-
pair_id,
|
| 460 |
-
data_loader,
|
| 461 |
-
probability_plot = True,
|
| 462 |
-
metrics=True,
|
| 463 |
-
confusion_matrix=True,
|
| 464 |
-
basic_summary=True):
|
| 465 |
-
|
| 466 |
-
# 1. Load model state
|
| 467 |
-
device, model = PvDeepSet_model.load_model_state()
|
| 468 |
-
|
| 469 |
-
# 2. Get probabilities
|
| 470 |
-
actual_probs, predicted_probs = PvDeepSet_model.get_model_results(
|
| 471 |
-
model=model, dataloader=data_loader, device=device, mode='evaluation'
|
| 472 |
-
)
|
| 473 |
-
|
| 474 |
-
class_names = ['C', 'L', 'I']
|
| 475 |
-
|
| 476 |
-
# --- 3. CREATE CONSOLIDATED RESULTS TABLE ---
|
| 477 |
-
eval_df = pd.DataFrame({
|
| 478 |
-
'pair_id': pair_id,
|
| 479 |
-
'true_C': actual_probs[:, 0],
|
| 480 |
-
'true_L': actual_probs[:, 1],
|
| 481 |
-
'true_I': actual_probs[:, 2],
|
| 482 |
-
'pred_C': predicted_probs[:, 0],
|
| 483 |
-
'pred_L': predicted_probs[:, 1],
|
| 484 |
-
'pred_I': predicted_probs[:, 2]
|
| 485 |
-
})
|
| 486 |
-
|
| 487 |
-
eval_df['true_class'] = [class_names[i] for i in np.argmax(actual_probs, axis=1)]
|
| 488 |
-
|
| 489 |
-
def classify_with_threshold(row):
|
| 490 |
-
probs = [row['pred_C'], row['pred_L'], row['pred_I']]
|
| 491 |
-
max_p = max(probs)
|
| 492 |
-
if max_p < 0.5:
|
| 493 |
-
return "undefined"
|
| 494 |
-
return class_names[np.argmax(probs)]
|
| 495 |
-
|
| 496 |
-
eval_df['predicted_class'] = eval_df.apply(classify_with_threshold, axis=1)
|
| 497 |
-
|
| 498 |
-
# --- 4. PREPARE DATA FOR PLOTS ---
|
| 499 |
-
name_to_idx = {name: i for i, name in enumerate(class_names)}
|
| 500 |
-
y_true_hard = np.array([name_to_idx[c] for c in eval_df['true_class']])
|
| 501 |
-
y_pred_hard = np.array([name_to_idx.get(c, -1) for c in eval_df['predicted_class']])
|
| 502 |
-
|
| 503 |
-
mask = y_pred_hard != -1
|
| 504 |
-
y_true_filtered = y_true_hard[mask]
|
| 505 |
-
y_pred_filtered = y_pred_hard[mask]
|
| 506 |
-
|
| 507 |
-
# --- INNER FUNCTION 1: PROBABILITY REGRESSION ---
|
| 508 |
-
def get_basic_summary(eval_df):
|
| 509 |
-
return f"\n--- Prediction Summary --- {eval_df['predicted_class'].value_counts()} --------------------------\n"
|
| 510 |
-
|
| 511 |
-
# --- INNER FUNCTION 2: PROBABILITY REGRESSION ---
|
| 512 |
-
def get_prob_plot(y_true, y_prob, names):
|
| 513 |
-
fig, axes = plt.subplots(1, 3, figsize=(18, 6), sharey=True)
|
| 514 |
-
for i, ax in enumerate(axes):
|
| 515 |
-
actual, predicted = y_true[:, i], y_prob[:, i]
|
| 516 |
-
jitter = np.random.normal(0, 0.008, size=actual.shape)
|
| 517 |
-
sns.regplot(x=actual + jitter, y=predicted, ax=ax,
|
| 518 |
-
scatter_kws={'alpha': 0.3, 's': 8, 'color': "#1672cf"},
|
| 519 |
-
line_kws={'color': '#e74c3c', 'linewidth': 2.5})
|
| 520 |
-
|
| 521 |
-
ax.set_title(f"{names[i]}\n$R^2 = {r2_score(actual, predicted):.3f}$", pad=20, fontsize=15)
|
| 522 |
-
ax.set_xlim(-0.05, 1.05); ax.set_ylim(-0.05, 1.05)
|
| 523 |
-
plt.tight_layout()
|
| 524 |
-
plt.close(fig)
|
| 525 |
-
return fig
|
| 526 |
-
|
| 527 |
-
# --- INNER FUNCTION 3: METRICS BAR & TABLE ---
|
| 528 |
-
def get_metrics_plot(y_true, y_pred, names):
|
| 529 |
-
report = classification_report(y_true, y_pred, target_names=names, output_dict=True)
|
| 530 |
-
df = pd.DataFrame(report).transpose()
|
| 531 |
-
|
| 532 |
-
fig = plt.figure(figsize=(8, 8))
|
| 533 |
-
gs = fig.add_gridspec(2, 1, height_ratios=[1, 0.5], hspace=0.3)
|
| 534 |
-
ax_bar = fig.add_subplot(gs[0])
|
| 535 |
-
ax_tbl = fig.add_subplot(gs[1])
|
| 536 |
-
|
| 537 |
-
# Bar Chart
|
| 538 |
-
df.loc[names, ['precision', 'recall', 'f1-score']].plot(kind='bar', ax=ax_bar, color=['#1672cf', '#4da1ff', '#aecff2'])
|
| 539 |
-
ax_bar.set_title("Performance Metrics", fontsize=15, weight='bold')
|
| 540 |
-
ax_bar.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=3)
|
| 541 |
-
|
| 542 |
-
# Table
|
| 543 |
-
ax_tbl.axis('off')
|
| 544 |
-
the_table = ax_tbl.table(cellText=df.round(3).values, rowLabels=df.index,
|
| 545 |
-
colLabels=df.columns, loc='center', cellLoc='center')
|
| 546 |
-
the_table.scale(1, 1.5)
|
| 547 |
-
|
| 548 |
-
plt.close(fig)
|
| 549 |
-
return fig
|
| 550 |
-
|
| 551 |
-
# --- INNER FUNCTION 4: CONFUSION MATRIX ---
|
| 552 |
-
def get_conf_matrix_plot(y_true, y_pred, names):
|
| 553 |
-
cm = confusion_matrix(y_true, y_pred)
|
| 554 |
-
cm_perc = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
|
| 555 |
-
annot_labels = (np.array([f"{c}\n({p:.1%})" for c, p in zip(cm.flatten(), cm_perc.flatten())])).reshape(3, 3)
|
| 556 |
-
|
| 557 |
-
fig, ax = plt.subplots(figsize=(7, 6))
|
| 558 |
-
sns.heatmap(cm_perc, annot=annot_labels, fmt="", cmap="Blues", ax=ax,
|
| 559 |
-
xticklabels=names, yticklabels=names, annot_kws={"size": 12, "weight": "bold"})
|
| 560 |
-
ax.set_title("Confusion Matrix", pad=20, fontsize=15, weight='bold')
|
| 561 |
-
ax.set_xlabel('Predicted'); ax.set_ylabel('True')
|
| 562 |
-
|
| 563 |
-
plt.close(fig)
|
| 564 |
-
return fig
|
| 565 |
-
|
| 566 |
-
results_df = eval_df.merge(meta_df, left_on='pair_id', right_on='sample_id_paired', how='inner')
|
| 567 |
-
|
| 568 |
-
# 5. Execute and Collect Plots
|
| 569 |
-
results = {
|
| 570 |
-
"results_table": results_df,
|
| 571 |
-
"data": (actual_probs, predicted_probs, y_true_hard, y_pred_hard)
|
| 572 |
-
}
|
| 573 |
-
|
| 574 |
-
if basic_summary:
|
| 575 |
-
results['basic_summary'] = get_basic_summary(eval_df)
|
| 576 |
-
if probability_plot:
|
| 577 |
-
results['prob_plot'] = get_prob_plot(actual_probs, predicted_probs, class_names)
|
| 578 |
-
|
| 579 |
-
if metrics:
|
| 580 |
-
results['metrics_plot'] = get_metrics_plot(y_true_filtered, y_pred_filtered, class_names)
|
| 581 |
-
|
| 582 |
-
if confusion_matrix:
|
| 583 |
-
results['conf_plot'] = get_conf_matrix_plot(y_true_filtered, y_pred_filtered, class_names)
|
| 584 |
-
|
| 585 |
-
return results
|
| 586 |
-
|
|
|
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
import plotly.express as px
|
| 9 |
from sklearn.metrics import r2_score
|
| 10 |
+
from DeepSets import PvDeepSets, Post_Model_Computation, PvRecNet_Plots
|
| 11 |
from sklearn.metrics import classification_report, confusion_matrix
|
| 12 |
+
import re
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
+
class PvDeepSet_Model:
|
| 18 |
@staticmethod
|
| 19 |
def load_model_state():
|
| 20 |
#-------------------------------------#
|
|
|
|
| 44 |
model.load_state_dict(torch.load(file_path, weights_only=True, map_location=device))
|
| 45 |
|
| 46 |
return device, model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
@staticmethod
|
| 50 |
def get_model_results(model, dataloader, device, threshold=0.5, mode='prediction'):
|
|
|
|
| 79 |
|
| 80 |
return pred_stack
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
@staticmethod
|
| 83 |
def run_prediction(meta_df,
|
| 84 |
pair_id,
|
|
|
|
| 86 |
basic_summary=True):
|
| 87 |
|
| 88 |
# 1. call a function that load saved model state
|
| 89 |
+
device, model = PvDeepSet_Model.load_model_state()
|
| 90 |
|
| 91 |
# 2. get model prediction result
|
| 92 |
# Shape: [N, 3] -> Column 0: C, Column 1: L, Column 2: I
|
| 93 |
+
predicted_probs = PvDeepSet_Model.get_model_results(model=model, dataloader=data_loader, device=device, mode='prediction')
|
| 94 |
|
| 95 |
# 3. Merge IDs with Probabilities
|
| 96 |
# Create a DataFrame from the results
|
|
|
|
| 103 |
results_df.insert(0, 'pair_id', pair_id)
|
| 104 |
|
| 105 |
results_df = results_df.merge(meta_df, left_on='pair_id', right_on='sample_id_paired', how='inner')
|
| 106 |
+
# model result post processing (prior refinement & marginal probabilities calculations)
|
| 107 |
+
results_df = Post_Model_Computation.result_post_processing(results_df, calc_NU_post=True, approx_joint=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
# 4. Hardclass Classification with Threshold Logic
|
|
|
|
| 123 |
# Apply the logic to create the new column
|
| 124 |
results_df['predicted_class'] = results_df.apply(classify_row, axis=1)
|
| 125 |
|
| 126 |
+
# ploting the recurrence classification results
|
| 127 |
+
donut_plot = PvRecNet_Plots.plot_donut_count(results_df)
|
| 128 |
+
probability_dist_plot = PvRecNet_Plots.plot_probability_dist(results_df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
columns = ['pair_id', 'patient_id', 'true_episode', 'prob_C', 'prob_L', 'prob_I', 'predicted_class']
|
| 132 |
results = {
|
| 133 |
+
'results_table':results_df,
|
| 134 |
'donut_plot': donut_plot,
|
| 135 |
'distribution_plot': probability_dist_plot
|
| 136 |
}
|
| 137 |
|
| 138 |
return results
|
| 139 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/PvDeepSetNet/src/DeepSets/Post_model_computation.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
class Post_Model_Computation:
|
| 5 |
+
@staticmethod
|
| 6 |
+
def compute_pv3rs_marginal_probabilities(results_df):
|
| 7 |
+
"""
|
| 8 |
+
Complete Python implementation of the Pv3Rs approx-joint marginalization logic.
|
| 9 |
+
|
| 10 |
+
1. Assigns pair_source based on the group cumcount index (+1).
|
| 11 |
+
2. Sequentially evaluates each true recurrence episode (j).
|
| 12 |
+
3. Normalizes and rounds the probabilities to 4 decimal places.
|
| 13 |
+
"""
|
| 14 |
+
# ====================================================================================
|
| 15 |
+
# STEP 1: Assign Source Position Index Using Your Cumcount Logic
|
| 16 |
+
# ====================================================================================
|
| 17 |
+
df = results_df.sort_values(['patient_id', 'true_episode']).copy()
|
| 18 |
+
|
| 19 |
+
# This identifies if the row is comparing against the 1st, 2nd, or 3rd previous episode
|
| 20 |
+
df['pair_source'] = df.groupby(['patient_id', 'true_episode']).cumcount() + 1
|
| 21 |
+
df = df.sort_values('pair_id')
|
| 22 |
+
|
| 23 |
+
marginal_results = []
|
| 24 |
+
|
| 25 |
+
# ====================================================================================
|
| 26 |
+
# STEP 2: Sequential Marginal Aggregation Engine
|
| 27 |
+
# ====================================================================================
|
| 28 |
+
for pid, group in df.groupby('patient_id'):
|
| 29 |
+
|
| 30 |
+
# Get unique episodes in chronological order
|
| 31 |
+
episodes = sorted(group['true_episode'].unique())
|
| 32 |
+
n_epi = len(episodes)
|
| 33 |
+
|
| 34 |
+
# We start calculating from the first recurrence (index 1)
|
| 35 |
+
for idx in range(1, n_epi):
|
| 36 |
+
curr_epi = episodes[idx] # Current recurrence episode 'j'
|
| 37 |
+
prev_epi = episodes[idx - 1] # Immediate predecessor 'j-1'
|
| 38 |
+
|
| 39 |
+
# Filter all pairs where 'true_episode' is our current episode
|
| 40 |
+
curr_recurrence_pairs = group[group['true_episode'] == curr_epi]
|
| 41 |
+
|
| 42 |
+
if curr_recurrence_pairs.empty:
|
| 43 |
+
continue
|
| 44 |
+
|
| 45 |
+
# --- 1. Compute C_unnorm (Consecutive pair constraint) ---
|
| 46 |
+
# Rule: Only look at the immediate predecessor index
|
| 47 |
+
c_row = curr_recurrence_pairs[curr_recurrence_pairs['pair_source'] == prev_epi]
|
| 48 |
+
C_unnorm = c_row['prob_C'].iloc[0] if not c_row.empty else 0.0
|
| 49 |
+
|
| 50 |
+
# --- 2. Compute L_unnorm & Track Source (Max operator across all i < j) ---
|
| 51 |
+
max_l_idx = curr_recurrence_pairs['prob_L'].idxmax()
|
| 52 |
+
L_unnorm = curr_recurrence_pairs.loc[max_l_idx, 'prob_L']
|
| 53 |
+
L_source = curr_recurrence_pairs.loc[max_l_idx, 'pair_source']
|
| 54 |
+
|
| 55 |
+
# --- 3. Compute I_unnorm (Min operator across all i < j) ---
|
| 56 |
+
I_unnorm = curr_recurrence_pairs['prob_I'].min()
|
| 57 |
+
|
| 58 |
+
# --- 4. Apply the Pv3Rs Conditional Correction Rule ---
|
| 59 |
+
if C_unnorm > 0.5 and I_unnorm < 0.001:
|
| 60 |
+
L_unnorm = c_row['prob_L'].iloc[0] if not c_row.empty else L_unnorm
|
| 61 |
+
L_source = prev_epi
|
| 62 |
+
|
| 63 |
+
# --- 5. Total Normalization & Formatted Rounding ---
|
| 64 |
+
total_mass = C_unnorm + L_unnorm + I_unnorm
|
| 65 |
+
|
| 66 |
+
if total_mass > 0:
|
| 67 |
+
C_marg = round(C_unnorm / total_mass, 4)
|
| 68 |
+
L_marg = round(L_unnorm / total_mass, 4)
|
| 69 |
+
I_marg = round(I_unnorm / total_mass, 4)
|
| 70 |
+
else:
|
| 71 |
+
C_marg, L_marg, I_marg = 0.0, 0.0, 0.0
|
| 72 |
+
|
| 73 |
+
# Append structured row for this specific recurrence outcome
|
| 74 |
+
marginal_results.append({
|
| 75 |
+
'sample_id': pid + '_' + str(int(curr_epi)),
|
| 76 |
+
'patient_id': pid,
|
| 77 |
+
'episode': int(curr_epi),
|
| 78 |
+
'relapse_source_epi': int(L_source),
|
| 79 |
+
'prob_C': C_marg,
|
| 80 |
+
'prob_L': L_marg,
|
| 81 |
+
'prob_I': I_marg
|
| 82 |
+
})
|
| 83 |
+
|
| 84 |
+
return pd.DataFrame(marginal_results)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
@staticmethod
|
| 88 |
+
def result_post_processing(results_df, calc_NU_post = True, approx_joint = True):
|
| 89 |
+
"""
|
| 90 |
+
result_df: PvDeepSet predicted results
|
| 91 |
+
calc_NU_post: calculate non uniform posterior (refine the posterior if the priors were not default)
|
| 92 |
+
approx_joint: approximate marginal probabilities from perwise results
|
| 93 |
+
"""
|
| 94 |
+
if calc_NU_post:
|
| 95 |
+
# unique_result = results_df[['pair_id', 'prior_C', 'prior_L', 'prior_I', 'prob_C', 'prob_L', 'prob_I']].drop_duplicates(ignore_index=True)
|
| 96 |
+
# 1. Align column names for math operations
|
| 97 |
+
# We create a temporary copy to ensure we multiply the right classes
|
| 98 |
+
df_priors = results_df[['prior_C', 'prior_L', 'prior_I']].rename(columns={'prior_C': 'C', 'prior_L': 'L', 'prior_I': 'I'})
|
| 99 |
+
|
| 100 |
+
df_post_uni = results_df[['prob_C', 'prob_L', 'prob_I']].rename(columns={'prob_C': 'C', 'prob_L': 'L', 'prob_I': 'I'})
|
| 101 |
+
|
| 102 |
+
# 2. Numerator: Multiply P_uniform(s|y) * P(s)
|
| 103 |
+
# Pandas handles row-matching automatically by index
|
| 104 |
+
numerator = df_post_uni * df_priors
|
| 105 |
+
|
| 106 |
+
# 3. Denominator: Sum across the columns for each row (Normalization)
|
| 107 |
+
denominator = numerator.sum(axis=1)
|
| 108 |
+
|
| 109 |
+
# 4. Final Recovery: Divide numerator by denominator
|
| 110 |
+
# axis=0 ensures the division happens row by row
|
| 111 |
+
df_post_non_uniform = numerator.divide(denominator, axis=0)
|
| 112 |
+
|
| 113 |
+
df_post_non_uniform['C'] = df_post_non_uniform['C'].round(4)
|
| 114 |
+
df_post_non_uniform['L'] = df_post_non_uniform['L'].round(4)
|
| 115 |
+
df_post_non_uniform['I'] = df_post_non_uniform['I'].round(4)
|
| 116 |
+
|
| 117 |
+
results_df['prob_C'] = df_post_non_uniform['C'].values
|
| 118 |
+
results_df['prob_L'] = df_post_non_uniform['L'].values
|
| 119 |
+
results_df['prob_I'] = df_post_non_uniform['I'].values
|
| 120 |
+
|
| 121 |
+
if approx_joint:
|
| 122 |
+
results_df = Post_Model_Computation.compute_pv3rs_marginal_probabilities(results_df=results_df)
|
| 123 |
+
return results_df
|
backend/PvDeepSetNet/src/DeepSets/Preprocess.py
CHANGED
|
@@ -133,6 +133,12 @@ class DataPreprocessor:
|
|
| 133 |
|
| 134 |
df.rename(columns={'episode':'true_episode', 'episode_order':'episode'}, inplace=True)
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
meta_info = df[['sample_id_paired', 'patient_id', 'true_episode', 'prior_C', 'prior_L', 'prior_I']].drop_duplicates().reset_index(drop=True)
|
| 137 |
|
| 138 |
return df, meta_info
|
|
@@ -146,10 +152,6 @@ class DataPreprocessor:
|
|
| 146 |
allele_to_id = alleles with their corresponding ids
|
| 147 |
Optimized Deep Sets preprocessing for Pv3Rs surrogate
|
| 148 |
"""
|
| 149 |
-
# checking the existance of prior columns, otherwise the default values will be assigned
|
| 150 |
-
required_cols = {'prior_C', 'prior_L', 'prior_I'}
|
| 151 |
-
if not required_cols.issubset(df.columns):
|
| 152 |
-
df['prior_C']=df['prior_L']=df['prior_I']=1/3
|
| 153 |
|
| 154 |
|
| 155 |
# reading allele dictionary
|
|
|
|
| 133 |
|
| 134 |
df.rename(columns={'episode':'true_episode', 'episode_order':'episode'}, inplace=True)
|
| 135 |
|
| 136 |
+
# checking the existance of prior columns, otherwise the default values will be assigned
|
| 137 |
+
required_cols = {'prior_C', 'prior_L', 'prior_I'}
|
| 138 |
+
if not required_cols.issubset(df.columns):
|
| 139 |
+
df['prior_C']=df['prior_L']=df['prior_I']=1/3
|
| 140 |
+
|
| 141 |
+
|
| 142 |
meta_info = df[['sample_id_paired', 'patient_id', 'true_episode', 'prior_C', 'prior_L', 'prior_I']].drop_duplicates().reset_index(drop=True)
|
| 143 |
|
| 144 |
return df, meta_info
|
|
|
|
| 152 |
allele_to_id = alleles with their corresponding ids
|
| 153 |
Optimized Deep Sets preprocessing for Pv3Rs surrogate
|
| 154 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
|
| 157 |
# reading allele dictionary
|
backend/PvDeepSetNet/src/DeepSets/PvRecNet_plots.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import plotly.express as px
|
| 3 |
+
|
| 4 |
+
class PvRecNet_Plots:
|
| 5 |
+
@staticmethod
|
| 6 |
+
def plot_donut_count(df):
|
| 7 |
+
# 1. Prepare the data
|
| 8 |
+
# Assuming 'df' is your processed dataframe from the previous step
|
| 9 |
+
counts_df = df['predicted_class'].value_counts().reset_index()
|
| 10 |
+
counts_df.columns = ['Class', 'Count']
|
| 11 |
+
map_rec = {'C':'C (Recrudescence)', 'L': 'L (Relapse)', 'I':'I (Reinfection)'}
|
| 12 |
+
|
| 13 |
+
counts_df['Class'] = counts_df['Class'].map(map_rec)
|
| 14 |
+
|
| 15 |
+
# 2. Create the Donut Chart
|
| 16 |
+
fig = px.pie(
|
| 17 |
+
counts_df,
|
| 18 |
+
values='Count',
|
| 19 |
+
names='Class',
|
| 20 |
+
hole=0.5, # This creates the "donut" effect
|
| 21 |
+
color='Class',
|
| 22 |
+
# Keeping colors consistent: Orange (C), Yellow (L), Teal (I)
|
| 23 |
+
color_discrete_map={
|
| 24 |
+
'C (Recrudescence)': '#ff4d00',
|
| 25 |
+
'L (Relapse)': '#e6b400',
|
| 26 |
+
'I (Reinfection)': '#1fb3c4'
|
| 27 |
+
},
|
| 28 |
+
template="plotly_white"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# 3. Refine the layout to match your previous style
|
| 32 |
+
fig.update_layout(
|
| 33 |
+
margin=dict(l=20, r=20, t=60, b=20),
|
| 34 |
+
height=500,
|
| 35 |
+
paper_bgcolor='white',
|
| 36 |
+
# Horizontal legend at the top
|
| 37 |
+
legend=dict(
|
| 38 |
+
orientation="h",
|
| 39 |
+
yanchor="bottom",
|
| 40 |
+
y=1.05,
|
| 41 |
+
xanchor="center",
|
| 42 |
+
x=0.5,
|
| 43 |
+
title=None
|
| 44 |
+
)
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
# 4. Enhance the traces (labels and percentages)
|
| 48 |
+
fig.update_traces(
|
| 49 |
+
textposition='inside',
|
| 50 |
+
textinfo='percent+label', # Shows the Class name and %
|
| 51 |
+
marker=dict(line=dict(color='#FFFFFF', width=2)) # Adds a small white gap between segments
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
return fig
|
| 55 |
+
|
| 56 |
+
@staticmethod
|
| 57 |
+
def plot_probability_dist(df, cols=['sample_id', 'prob_C', 'prob_L','prob_I','predicted_class']):
|
| 58 |
+
|
| 59 |
+
df = df.copy()
|
| 60 |
+
df = df[cols].drop_duplicates().reset_index(drop=True)
|
| 61 |
+
|
| 62 |
+
# Grouped and sorted blocks
|
| 63 |
+
df_C = df[df.predicted_class == 'C'].sort_values(cols[1], ascending=False).reset_index(drop=True)
|
| 64 |
+
df_L = df[df.predicted_class == 'L'].sort_values(cols[2], ascending=False).reset_index(drop=True)
|
| 65 |
+
df_I = df[df.predicted_class == 'I'].sort_values(cols[3], ascending=False).reset_index(drop=True)
|
| 66 |
+
|
| 67 |
+
df_sorted = pd.concat([df_C, df_L, df_I], ignore_index=True)
|
| 68 |
+
|
| 69 |
+
df_long = df_sorted.melt(
|
| 70 |
+
id_vars=cols[0],
|
| 71 |
+
value_vars=cols[1:4],
|
| 72 |
+
var_name='Probability_Type',
|
| 73 |
+
value_name='Probability'
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
fig = px.bar(
|
| 77 |
+
df_long,
|
| 78 |
+
x=cols[0],
|
| 79 |
+
y="Probability",
|
| 80 |
+
color="Probability_Type",
|
| 81 |
+
color_discrete_sequence=['#ff4d00', '#e6b400', '#1fb3c4'],
|
| 82 |
+
category_orders={cols[0]: df_sorted[cols[0]].tolist()},
|
| 83 |
+
template="plotly_white" # Sets white background and clean gridlines
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
fig.update_layout(
|
| 87 |
+
title=None,
|
| 88 |
+
margin=dict(l=50, r=20, t=60, b=50), # Adjusted for axis labels
|
| 89 |
+
height=500,
|
| 90 |
+
paper_bgcolor='white',
|
| 91 |
+
plot_bgcolor='white',
|
| 92 |
+
|
| 93 |
+
# Horizontal legend at the top
|
| 94 |
+
legend=dict(
|
| 95 |
+
orientation="h",
|
| 96 |
+
yanchor="bottom",
|
| 97 |
+
y=1.02,
|
| 98 |
+
xanchor="center",
|
| 99 |
+
x=0.5,
|
| 100 |
+
title=None
|
| 101 |
+
),
|
| 102 |
+
|
| 103 |
+
xaxis=dict(
|
| 104 |
+
title="Samples", # Restored the label
|
| 105 |
+
showticklabels=False, # Keeps specific IDs hidden for cleanliness
|
| 106 |
+
ticks="",
|
| 107 |
+
linecolor='black', # Adds a crisp base line
|
| 108 |
+
showgrid=False
|
| 109 |
+
),
|
| 110 |
+
|
| 111 |
+
yaxis=dict(
|
| 112 |
+
title="Probability",
|
| 113 |
+
range=[0, 1],
|
| 114 |
+
tickformat=".1f",
|
| 115 |
+
linecolor='black',
|
| 116 |
+
gridcolor='lightgrey' # Subtle grid for probability reference
|
| 117 |
+
),
|
| 118 |
+
|
| 119 |
+
bargap=0
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
return fig
|
backend/PvDeepSetNet/src/DeepSets/__init__.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
-
from .Preprocess import DataPreprocessor
|
| 2 |
from .Model import PvDeepSets
|
|
|
|
|
|
|
|
|
|
| 3 |
from .DeepSets_pipeline import run_prediction
|
| 4 |
-
from .Model_result import
|
|
|
|
|
|
|
| 1 |
from .Model import PvDeepSets
|
| 2 |
+
from .PvRecNet_plots import PvRecNet_Plots
|
| 3 |
+
from .Post_model_computation import Post_Model_Computation
|
| 4 |
+
from .Preprocess import DataPreprocessor
|
| 5 |
from .DeepSets_pipeline import run_prediction
|
| 6 |
+
from .Model_result import PvDeepSet_Model
|
backend/PvDeepSetNet/src/DeepSets/__pycache__/DeepSets_pipeline.cpython-310.pyc
CHANGED
|
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/DeepSets_pipeline.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/DeepSets_pipeline.cpython-310.pyc differ
|
|
|
backend/PvDeepSetNet/src/DeepSets/__pycache__/Model_result.cpython-310.pyc
CHANGED
|
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/Model_result.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/Model_result.cpython-310.pyc differ
|
|
|
backend/PvDeepSetNet/src/DeepSets/__pycache__/Post_model_computation.cpython-310.pyc
ADDED
|
Binary file (2.85 kB). View file
|
|
|
backend/PvDeepSetNet/src/DeepSets/__pycache__/Preprocess.cpython-310.pyc
CHANGED
|
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/Preprocess.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/Preprocess.cpython-310.pyc differ
|
|
|
backend/PvDeepSetNet/src/DeepSets/__pycache__/PvRecNet_plots.cpython-310.pyc
ADDED
|
Binary file (2.63 kB). View file
|
|
|
backend/PvDeepSetNet/src/DeepSets/__pycache__/__init__.cpython-310.pyc
CHANGED
|
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/__init__.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/__init__.cpython-310.pyc differ
|
|
|
backend/PvDeepSetNet/tests/temp.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"id": "cf18a668",
|
| 7 |
"metadata": {},
|
| 8 |
"outputs": [],
|
|
@@ -143,7 +143,7 @@
|
|
| 143 |
},
|
| 144 |
{
|
| 145 |
"cell_type": "code",
|
| 146 |
-
"execution_count":
|
| 147 |
"metadata": {},
|
| 148 |
"outputs": [],
|
| 149 |
"source": [
|
|
@@ -156,7 +156,7 @@
|
|
| 156 |
},
|
| 157 |
{
|
| 158 |
"cell_type": "code",
|
| 159 |
-
"execution_count":
|
| 160 |
"id": "5d400e68",
|
| 161 |
"metadata": {},
|
| 162 |
"outputs": [
|
|
@@ -195,6 +195,1716 @@
|
|
| 195 |
"temp.sample_id_paired.nunique()"
|
| 196 |
]
|
| 197 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
{
|
| 199 |
"cell_type": "code",
|
| 200 |
"execution_count": null,
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
"id": "cf18a668",
|
| 7 |
"metadata": {},
|
| 8 |
"outputs": [],
|
|
|
|
| 143 |
},
|
| 144 |
{
|
| 145 |
"cell_type": "code",
|
| 146 |
+
"execution_count": 3,
|
| 147 |
"metadata": {},
|
| 148 |
"outputs": [],
|
| 149 |
"source": [
|
|
|
|
| 156 |
},
|
| 157 |
{
|
| 158 |
"cell_type": "code",
|
| 159 |
+
"execution_count": 79,
|
| 160 |
"id": "5d400e68",
|
| 161 |
"metadata": {},
|
| 162 |
"outputs": [
|
|
|
|
| 195 |
"temp.sample_id_paired.nunique()"
|
| 196 |
]
|
| 197 |
},
|
| 198 |
+
{
|
| 199 |
+
"cell_type": "code",
|
| 200 |
+
"execution_count": 43,
|
| 201 |
+
"id": "53fd6668",
|
| 202 |
+
"metadata": {},
|
| 203 |
+
"outputs": [
|
| 204 |
+
{
|
| 205 |
+
"data": {
|
| 206 |
+
"text/html": [
|
| 207 |
+
"<div>\n",
|
| 208 |
+
"<style scoped>\n",
|
| 209 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 210 |
+
" vertical-align: middle;\n",
|
| 211 |
+
" }\n",
|
| 212 |
+
"\n",
|
| 213 |
+
" .dataframe tbody tr th {\n",
|
| 214 |
+
" vertical-align: top;\n",
|
| 215 |
+
" }\n",
|
| 216 |
+
"\n",
|
| 217 |
+
" .dataframe thead th {\n",
|
| 218 |
+
" text-align: right;\n",
|
| 219 |
+
" }\n",
|
| 220 |
+
"</style>\n",
|
| 221 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 222 |
+
" <thead>\n",
|
| 223 |
+
" <tr style=\"text-align: right;\">\n",
|
| 224 |
+
" <th></th>\n",
|
| 225 |
+
" <th>sample_id_paired</th>\n",
|
| 226 |
+
" <th>pair_id</th>\n",
|
| 227 |
+
" <th>patient_id</th>\n",
|
| 228 |
+
" <th>sample_id</th>\n",
|
| 229 |
+
" <th>episode</th>\n",
|
| 230 |
+
" <th>true_episode</th>\n",
|
| 231 |
+
" <th>marker</th>\n",
|
| 232 |
+
" <th>allele</th>\n",
|
| 233 |
+
" <th>frequency</th>\n",
|
| 234 |
+
" <th>MOI</th>\n",
|
| 235 |
+
" <th>...</th>\n",
|
| 236 |
+
" <th>prior_C</th>\n",
|
| 237 |
+
" <th>prior_L</th>\n",
|
| 238 |
+
" <th>prior_I</th>\n",
|
| 239 |
+
" <th>post_C</th>\n",
|
| 240 |
+
" <th>post_L</th>\n",
|
| 241 |
+
" <th>post_I</th>\n",
|
| 242 |
+
" <th>recurrence_class</th>\n",
|
| 243 |
+
" <th>sets</th>\n",
|
| 244 |
+
" <th>source</th>\n",
|
| 245 |
+
" <th>pair_order</th>\n",
|
| 246 |
+
" </tr>\n",
|
| 247 |
+
" </thead>\n",
|
| 248 |
+
" <tbody>\n",
|
| 249 |
+
" <tr>\n",
|
| 250 |
+
" <th>0</th>\n",
|
| 251 |
+
" <td>Sero-040-DF_4</td>\n",
|
| 252 |
+
" <td>Sero-040_4</td>\n",
|
| 253 |
+
" <td>Sero-040</td>\n",
|
| 254 |
+
" <td>Sero-040-R04</td>\n",
|
| 255 |
+
" <td>1</td>\n",
|
| 256 |
+
" <td>2.0</td>\n",
|
| 257 |
+
" <td>Chr09</td>\n",
|
| 258 |
+
" <td>Chr09-1</td>\n",
|
| 259 |
+
" <td>0.371429</td>\n",
|
| 260 |
+
" <td>4</td>\n",
|
| 261 |
+
" <td>...</td>\n",
|
| 262 |
+
" <td>0.333333</td>\n",
|
| 263 |
+
" <td>0.333333</td>\n",
|
| 264 |
+
" <td>0.333333</td>\n",
|
| 265 |
+
" <td>0.0</td>\n",
|
| 266 |
+
" <td>0.174856</td>\n",
|
| 267 |
+
" <td>0.825144</td>\n",
|
| 268 |
+
" <td>I</td>\n",
|
| 269 |
+
" <td>test</td>\n",
|
| 270 |
+
" <td>real</td>\n",
|
| 271 |
+
" <td>4</td>\n",
|
| 272 |
+
" </tr>\n",
|
| 273 |
+
" <tr>\n",
|
| 274 |
+
" <th>1</th>\n",
|
| 275 |
+
" <td>Sero-040-DF_4</td>\n",
|
| 276 |
+
" <td>Sero-040_4</td>\n",
|
| 277 |
+
" <td>Sero-040</td>\n",
|
| 278 |
+
" <td>Sero-040-R04</td>\n",
|
| 279 |
+
" <td>1</td>\n",
|
| 280 |
+
" <td>2.0</td>\n",
|
| 281 |
+
" <td>Chr09</td>\n",
|
| 282 |
+
" <td>Chr09-3</td>\n",
|
| 283 |
+
" <td>0.228571</td>\n",
|
| 284 |
+
" <td>4</td>\n",
|
| 285 |
+
" <td>...</td>\n",
|
| 286 |
+
" <td>0.333333</td>\n",
|
| 287 |
+
" <td>0.333333</td>\n",
|
| 288 |
+
" <td>0.333333</td>\n",
|
| 289 |
+
" <td>0.0</td>\n",
|
| 290 |
+
" <td>0.174856</td>\n",
|
| 291 |
+
" <td>0.825144</td>\n",
|
| 292 |
+
" <td>I</td>\n",
|
| 293 |
+
" <td>test</td>\n",
|
| 294 |
+
" <td>real</td>\n",
|
| 295 |
+
" <td>4</td>\n",
|
| 296 |
+
" </tr>\n",
|
| 297 |
+
" <tr>\n",
|
| 298 |
+
" <th>2</th>\n",
|
| 299 |
+
" <td>Sero-040-DF_4</td>\n",
|
| 300 |
+
" <td>Sero-040_4</td>\n",
|
| 301 |
+
" <td>Sero-040</td>\n",
|
| 302 |
+
" <td>Sero-040-R04</td>\n",
|
| 303 |
+
" <td>1</td>\n",
|
| 304 |
+
" <td>2.0</td>\n",
|
| 305 |
+
" <td>Chr10</td>\n",
|
| 306 |
+
" <td>Chr10-1</td>\n",
|
| 307 |
+
" <td>0.406593</td>\n",
|
| 308 |
+
" <td>4</td>\n",
|
| 309 |
+
" <td>...</td>\n",
|
| 310 |
+
" <td>0.333333</td>\n",
|
| 311 |
+
" <td>0.333333</td>\n",
|
| 312 |
+
" <td>0.333333</td>\n",
|
| 313 |
+
" <td>0.0</td>\n",
|
| 314 |
+
" <td>0.174856</td>\n",
|
| 315 |
+
" <td>0.825144</td>\n",
|
| 316 |
+
" <td>I</td>\n",
|
| 317 |
+
" <td>test</td>\n",
|
| 318 |
+
" <td>real</td>\n",
|
| 319 |
+
" <td>4</td>\n",
|
| 320 |
+
" </tr>\n",
|
| 321 |
+
" <tr>\n",
|
| 322 |
+
" <th>3</th>\n",
|
| 323 |
+
" <td>Sero-040-DF_4</td>\n",
|
| 324 |
+
" <td>Sero-040_4</td>\n",
|
| 325 |
+
" <td>Sero-040</td>\n",
|
| 326 |
+
" <td>Sero-040-R04</td>\n",
|
| 327 |
+
" <td>1</td>\n",
|
| 328 |
+
" <td>2.0</td>\n",
|
| 329 |
+
" <td>Chr11</td>\n",
|
| 330 |
+
" <td>Chr11-2</td>\n",
|
| 331 |
+
" <td>0.168317</td>\n",
|
| 332 |
+
" <td>4</td>\n",
|
| 333 |
+
" <td>...</td>\n",
|
| 334 |
+
" <td>0.333333</td>\n",
|
| 335 |
+
" <td>0.333333</td>\n",
|
| 336 |
+
" <td>0.333333</td>\n",
|
| 337 |
+
" <td>0.0</td>\n",
|
| 338 |
+
" <td>0.174856</td>\n",
|
| 339 |
+
" <td>0.825144</td>\n",
|
| 340 |
+
" <td>I</td>\n",
|
| 341 |
+
" <td>test</td>\n",
|
| 342 |
+
" <td>real</td>\n",
|
| 343 |
+
" <td>4</td>\n",
|
| 344 |
+
" </tr>\n",
|
| 345 |
+
" <tr>\n",
|
| 346 |
+
" <th>4</th>\n",
|
| 347 |
+
" <td>Sero-040-DF_4</td>\n",
|
| 348 |
+
" <td>Sero-040_4</td>\n",
|
| 349 |
+
" <td>Sero-040</td>\n",
|
| 350 |
+
" <td>Sero-040-R04</td>\n",
|
| 351 |
+
" <td>1</td>\n",
|
| 352 |
+
" <td>2.0</td>\n",
|
| 353 |
+
" <td>Chr11</td>\n",
|
| 354 |
+
" <td>Chr11-1</td>\n",
|
| 355 |
+
" <td>0.495050</td>\n",
|
| 356 |
+
" <td>4</td>\n",
|
| 357 |
+
" <td>...</td>\n",
|
| 358 |
+
" <td>0.333333</td>\n",
|
| 359 |
+
" <td>0.333333</td>\n",
|
| 360 |
+
" <td>0.333333</td>\n",
|
| 361 |
+
" <td>0.0</td>\n",
|
| 362 |
+
" <td>0.174856</td>\n",
|
| 363 |
+
" <td>0.825144</td>\n",
|
| 364 |
+
" <td>I</td>\n",
|
| 365 |
+
" <td>test</td>\n",
|
| 366 |
+
" <td>real</td>\n",
|
| 367 |
+
" <td>4</td>\n",
|
| 368 |
+
" </tr>\n",
|
| 369 |
+
" <tr>\n",
|
| 370 |
+
" <th>...</th>\n",
|
| 371 |
+
" <td>...</td>\n",
|
| 372 |
+
" <td>...</td>\n",
|
| 373 |
+
" <td>...</td>\n",
|
| 374 |
+
" <td>...</td>\n",
|
| 375 |
+
" <td>...</td>\n",
|
| 376 |
+
" <td>...</td>\n",
|
| 377 |
+
" <td>...</td>\n",
|
| 378 |
+
" <td>...</td>\n",
|
| 379 |
+
" <td>...</td>\n",
|
| 380 |
+
" <td>...</td>\n",
|
| 381 |
+
" <td>...</td>\n",
|
| 382 |
+
" <td>...</td>\n",
|
| 383 |
+
" <td>...</td>\n",
|
| 384 |
+
" <td>...</td>\n",
|
| 385 |
+
" <td>...</td>\n",
|
| 386 |
+
" <td>...</td>\n",
|
| 387 |
+
" <td>...</td>\n",
|
| 388 |
+
" <td>...</td>\n",
|
| 389 |
+
" <td>...</td>\n",
|
| 390 |
+
" <td>...</td>\n",
|
| 391 |
+
" <td>...</td>\n",
|
| 392 |
+
" </tr>\n",
|
| 393 |
+
" <tr>\n",
|
| 394 |
+
" <th>1607</th>\n",
|
| 395 |
+
" <td>Sero-109-DF_3</td>\n",
|
| 396 |
+
" <td>Sero-109_3</td>\n",
|
| 397 |
+
" <td>Sero-109</td>\n",
|
| 398 |
+
" <td>Sero-109-R08</td>\n",
|
| 399 |
+
" <td>2</td>\n",
|
| 400 |
+
" <td>3.0</td>\n",
|
| 401 |
+
" <td>Chr07</td>\n",
|
| 402 |
+
" <td>Chr07-1</td>\n",
|
| 403 |
+
" <td>0.275641</td>\n",
|
| 404 |
+
" <td>3</td>\n",
|
| 405 |
+
" <td>...</td>\n",
|
| 406 |
+
" <td>0.333333</td>\n",
|
| 407 |
+
" <td>0.333333</td>\n",
|
| 408 |
+
" <td>0.333333</td>\n",
|
| 409 |
+
" <td>0.0</td>\n",
|
| 410 |
+
" <td>0.703100</td>\n",
|
| 411 |
+
" <td>0.296900</td>\n",
|
| 412 |
+
" <td>L</td>\n",
|
| 413 |
+
" <td>test</td>\n",
|
| 414 |
+
" <td>real</td>\n",
|
| 415 |
+
" <td>3</td>\n",
|
| 416 |
+
" </tr>\n",
|
| 417 |
+
" <tr>\n",
|
| 418 |
+
" <th>1608</th>\n",
|
| 419 |
+
" <td>Sero-109-DF_3</td>\n",
|
| 420 |
+
" <td>Sero-109_3</td>\n",
|
| 421 |
+
" <td>Sero-109</td>\n",
|
| 422 |
+
" <td>Sero-109-R08</td>\n",
|
| 423 |
+
" <td>2</td>\n",
|
| 424 |
+
" <td>3.0</td>\n",
|
| 425 |
+
" <td>Chr05</td>\n",
|
| 426 |
+
" <td>Chr05-5</td>\n",
|
| 427 |
+
" <td>0.124183</td>\n",
|
| 428 |
+
" <td>3</td>\n",
|
| 429 |
+
" <td>...</td>\n",
|
| 430 |
+
" <td>0.333333</td>\n",
|
| 431 |
+
" <td>0.333333</td>\n",
|
| 432 |
+
" <td>0.333333</td>\n",
|
| 433 |
+
" <td>0.0</td>\n",
|
| 434 |
+
" <td>0.703100</td>\n",
|
| 435 |
+
" <td>0.296900</td>\n",
|
| 436 |
+
" <td>L</td>\n",
|
| 437 |
+
" <td>test</td>\n",
|
| 438 |
+
" <td>real</td>\n",
|
| 439 |
+
" <td>3</td>\n",
|
| 440 |
+
" </tr>\n",
|
| 441 |
+
" <tr>\n",
|
| 442 |
+
" <th>1609</th>\n",
|
| 443 |
+
" <td>Sero-109-DF_3</td>\n",
|
| 444 |
+
" <td>Sero-109_3</td>\n",
|
| 445 |
+
" <td>Sero-109</td>\n",
|
| 446 |
+
" <td>Sero-109-R08</td>\n",
|
| 447 |
+
" <td>2</td>\n",
|
| 448 |
+
" <td>3.0</td>\n",
|
| 449 |
+
" <td>Chr05</td>\n",
|
| 450 |
+
" <td>Chr05-2</td>\n",
|
| 451 |
+
" <td>0.254902</td>\n",
|
| 452 |
+
" <td>3</td>\n",
|
| 453 |
+
" <td>...</td>\n",
|
| 454 |
+
" <td>0.333333</td>\n",
|
| 455 |
+
" <td>0.333333</td>\n",
|
| 456 |
+
" <td>0.333333</td>\n",
|
| 457 |
+
" <td>0.0</td>\n",
|
| 458 |
+
" <td>0.703100</td>\n",
|
| 459 |
+
" <td>0.296900</td>\n",
|
| 460 |
+
" <td>L</td>\n",
|
| 461 |
+
" <td>test</td>\n",
|
| 462 |
+
" <td>real</td>\n",
|
| 463 |
+
" <td>3</td>\n",
|
| 464 |
+
" </tr>\n",
|
| 465 |
+
" <tr>\n",
|
| 466 |
+
" <th>1610</th>\n",
|
| 467 |
+
" <td>Sero-109-DF_3</td>\n",
|
| 468 |
+
" <td>Sero-109_3</td>\n",
|
| 469 |
+
" <td>Sero-109</td>\n",
|
| 470 |
+
" <td>Sero-109-R08</td>\n",
|
| 471 |
+
" <td>2</td>\n",
|
| 472 |
+
" <td>3.0</td>\n",
|
| 473 |
+
" <td>Chr05</td>\n",
|
| 474 |
+
" <td>Chr05-3</td>\n",
|
| 475 |
+
" <td>0.196078</td>\n",
|
| 476 |
+
" <td>3</td>\n",
|
| 477 |
+
" <td>...</td>\n",
|
| 478 |
+
" <td>0.333333</td>\n",
|
| 479 |
+
" <td>0.333333</td>\n",
|
| 480 |
+
" <td>0.333333</td>\n",
|
| 481 |
+
" <td>0.0</td>\n",
|
| 482 |
+
" <td>0.703100</td>\n",
|
| 483 |
+
" <td>0.296900</td>\n",
|
| 484 |
+
" <td>L</td>\n",
|
| 485 |
+
" <td>test</td>\n",
|
| 486 |
+
" <td>real</td>\n",
|
| 487 |
+
" <td>3</td>\n",
|
| 488 |
+
" </tr>\n",
|
| 489 |
+
" <tr>\n",
|
| 490 |
+
" <th>1611</th>\n",
|
| 491 |
+
" <td>Sero-109-DF_3</td>\n",
|
| 492 |
+
" <td>Sero-109_3</td>\n",
|
| 493 |
+
" <td>Sero-109</td>\n",
|
| 494 |
+
" <td>Sero-109-R08</td>\n",
|
| 495 |
+
" <td>2</td>\n",
|
| 496 |
+
" <td>3.0</td>\n",
|
| 497 |
+
" <td>Chr09</td>\n",
|
| 498 |
+
" <td>Chr09-2</td>\n",
|
| 499 |
+
" <td>0.250000</td>\n",
|
| 500 |
+
" <td>3</td>\n",
|
| 501 |
+
" <td>...</td>\n",
|
| 502 |
+
" <td>0.333333</td>\n",
|
| 503 |
+
" <td>0.333333</td>\n",
|
| 504 |
+
" <td>0.333333</td>\n",
|
| 505 |
+
" <td>0.0</td>\n",
|
| 506 |
+
" <td>0.703100</td>\n",
|
| 507 |
+
" <td>0.296900</td>\n",
|
| 508 |
+
" <td>L</td>\n",
|
| 509 |
+
" <td>test</td>\n",
|
| 510 |
+
" <td>real</td>\n",
|
| 511 |
+
" <td>3</td>\n",
|
| 512 |
+
" </tr>\n",
|
| 513 |
+
" </tbody>\n",
|
| 514 |
+
"</table>\n",
|
| 515 |
+
"<p>1612 rows × 22 columns</p>\n",
|
| 516 |
+
"</div>"
|
| 517 |
+
],
|
| 518 |
+
"text/plain": [
|
| 519 |
+
" sample_id_paired pair_id patient_id sample_id episode \\\n",
|
| 520 |
+
"0 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
|
| 521 |
+
"1 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
|
| 522 |
+
"2 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
|
| 523 |
+
"3 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
|
| 524 |
+
"4 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
|
| 525 |
+
"... ... ... ... ... ... \n",
|
| 526 |
+
"1607 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
|
| 527 |
+
"1608 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
|
| 528 |
+
"1609 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
|
| 529 |
+
"1610 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
|
| 530 |
+
"1611 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
|
| 531 |
+
"\n",
|
| 532 |
+
" true_episode marker allele frequency MOI ... prior_C prior_L \\\n",
|
| 533 |
+
"0 2.0 Chr09 Chr09-1 0.371429 4 ... 0.333333 0.333333 \n",
|
| 534 |
+
"1 2.0 Chr09 Chr09-3 0.228571 4 ... 0.333333 0.333333 \n",
|
| 535 |
+
"2 2.0 Chr10 Chr10-1 0.406593 4 ... 0.333333 0.333333 \n",
|
| 536 |
+
"3 2.0 Chr11 Chr11-2 0.168317 4 ... 0.333333 0.333333 \n",
|
| 537 |
+
"4 2.0 Chr11 Chr11-1 0.495050 4 ... 0.333333 0.333333 \n",
|
| 538 |
+
"... ... ... ... ... ... ... ... ... \n",
|
| 539 |
+
"1607 3.0 Chr07 Chr07-1 0.275641 3 ... 0.333333 0.333333 \n",
|
| 540 |
+
"1608 3.0 Chr05 Chr05-5 0.124183 3 ... 0.333333 0.333333 \n",
|
| 541 |
+
"1609 3.0 Chr05 Chr05-2 0.254902 3 ... 0.333333 0.333333 \n",
|
| 542 |
+
"1610 3.0 Chr05 Chr05-3 0.196078 3 ... 0.333333 0.333333 \n",
|
| 543 |
+
"1611 3.0 Chr09 Chr09-2 0.250000 3 ... 0.333333 0.333333 \n",
|
| 544 |
+
"\n",
|
| 545 |
+
" prior_I post_C post_L post_I recurrence_class sets source \\\n",
|
| 546 |
+
"0 0.333333 0.0 0.174856 0.825144 I test real \n",
|
| 547 |
+
"1 0.333333 0.0 0.174856 0.825144 I test real \n",
|
| 548 |
+
"2 0.333333 0.0 0.174856 0.825144 I test real \n",
|
| 549 |
+
"3 0.333333 0.0 0.174856 0.825144 I test real \n",
|
| 550 |
+
"4 0.333333 0.0 0.174856 0.825144 I test real \n",
|
| 551 |
+
"... ... ... ... ... ... ... ... \n",
|
| 552 |
+
"1607 0.333333 0.0 0.703100 0.296900 L test real \n",
|
| 553 |
+
"1608 0.333333 0.0 0.703100 0.296900 L test real \n",
|
| 554 |
+
"1609 0.333333 0.0 0.703100 0.296900 L test real \n",
|
| 555 |
+
"1610 0.333333 0.0 0.703100 0.296900 L test real \n",
|
| 556 |
+
"1611 0.333333 0.0 0.703100 0.296900 L test real \n",
|
| 557 |
+
"\n",
|
| 558 |
+
" pair_order \n",
|
| 559 |
+
"0 4 \n",
|
| 560 |
+
"1 4 \n",
|
| 561 |
+
"2 4 \n",
|
| 562 |
+
"3 4 \n",
|
| 563 |
+
"4 4 \n",
|
| 564 |
+
"... ... \n",
|
| 565 |
+
"1607 3 \n",
|
| 566 |
+
"1608 3 \n",
|
| 567 |
+
"1609 3 \n",
|
| 568 |
+
"1610 3 \n",
|
| 569 |
+
"1611 3 \n",
|
| 570 |
+
"\n",
|
| 571 |
+
"[1612 rows x 22 columns]"
|
| 572 |
+
]
|
| 573 |
+
},
|
| 574 |
+
"execution_count": 43,
|
| 575 |
+
"metadata": {},
|
| 576 |
+
"output_type": "execute_result"
|
| 577 |
+
}
|
| 578 |
+
],
|
| 579 |
+
"source": [
|
| 580 |
+
"temp"
|
| 581 |
+
]
|
| 582 |
+
},
|
| 583 |
+
{
|
| 584 |
+
"cell_type": "code",
|
| 585 |
+
"execution_count": 24,
|
| 586 |
+
"id": "de61dbd8",
|
| 587 |
+
"metadata": {},
|
| 588 |
+
"outputs": [
|
| 589 |
+
{
|
| 590 |
+
"data": {
|
| 591 |
+
"text/plain": [
|
| 592 |
+
"1.0000000000000002"
|
| 593 |
+
]
|
| 594 |
+
},
|
| 595 |
+
"execution_count": 24,
|
| 596 |
+
"metadata": {},
|
| 597 |
+
"output_type": "execute_result"
|
| 598 |
+
}
|
| 599 |
+
],
|
| 600 |
+
"source": [
|
| 601 |
+
"temp3.values[2, 1:4].sum()"
|
| 602 |
+
]
|
| 603 |
+
},
|
| 604 |
+
{
|
| 605 |
+
"cell_type": "code",
|
| 606 |
+
"execution_count": 4,
|
| 607 |
+
"id": "5c0986c4",
|
| 608 |
+
"metadata": {},
|
| 609 |
+
"outputs": [
|
| 610 |
+
{
|
| 611 |
+
"name": "stdout",
|
| 612 |
+
"output_type": "stream",
|
| 613 |
+
"text": [
|
| 614 |
+
"143\n"
|
| 615 |
+
]
|
| 616 |
+
}
|
| 617 |
+
],
|
| 618 |
+
"source": [
|
| 619 |
+
"temp3 = run_prediction(temp)\n",
|
| 620 |
+
"# temp3\n",
|
| 621 |
+
"# temp3['C'] = temp3['C'].round(4)\n",
|
| 622 |
+
"# temp3['L'] = temp3['L'].round(4)\n",
|
| 623 |
+
"# temp3['I'] = temp3['I'].round(4)"
|
| 624 |
+
]
|
| 625 |
+
},
|
| 626 |
+
{
|
| 627 |
+
"cell_type": "code",
|
| 628 |
+
"execution_count": 35,
|
| 629 |
+
"id": "2488da46",
|
| 630 |
+
"metadata": {},
|
| 631 |
+
"outputs": [
|
| 632 |
+
{
|
| 633 |
+
"data": {
|
| 634 |
+
"text/html": [
|
| 635 |
+
"<div>\n",
|
| 636 |
+
"<style scoped>\n",
|
| 637 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 638 |
+
" vertical-align: middle;\n",
|
| 639 |
+
" }\n",
|
| 640 |
+
"\n",
|
| 641 |
+
" .dataframe tbody tr th {\n",
|
| 642 |
+
" vertical-align: top;\n",
|
| 643 |
+
" }\n",
|
| 644 |
+
"\n",
|
| 645 |
+
" .dataframe thead th {\n",
|
| 646 |
+
" text-align: right;\n",
|
| 647 |
+
" }\n",
|
| 648 |
+
"</style>\n",
|
| 649 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 650 |
+
" <thead>\n",
|
| 651 |
+
" <tr style=\"text-align: right;\">\n",
|
| 652 |
+
" <th></th>\n",
|
| 653 |
+
" <th>pair_id</th>\n",
|
| 654 |
+
" <th>prior_C</th>\n",
|
| 655 |
+
" <th>prior_L</th>\n",
|
| 656 |
+
" <th>prior_I</th>\n",
|
| 657 |
+
" <th>prob_C</th>\n",
|
| 658 |
+
" <th>prob_L</th>\n",
|
| 659 |
+
" <th>prob_I</th>\n",
|
| 660 |
+
" </tr>\n",
|
| 661 |
+
" </thead>\n",
|
| 662 |
+
" <tbody>\n",
|
| 663 |
+
" </tbody>\n",
|
| 664 |
+
"</table>\n",
|
| 665 |
+
"</div>"
|
| 666 |
+
],
|
| 667 |
+
"text/plain": [
|
| 668 |
+
"Empty DataFrame\n",
|
| 669 |
+
"Columns: [pair_id, prior_C, prior_L, prior_I, prob_C, prob_L, prob_I]\n",
|
| 670 |
+
"Index: []"
|
| 671 |
+
]
|
| 672 |
+
},
|
| 673 |
+
"execution_count": 35,
|
| 674 |
+
"metadata": {},
|
| 675 |
+
"output_type": "execute_result"
|
| 676 |
+
}
|
| 677 |
+
],
|
| 678 |
+
"source": [
|
| 679 |
+
"temp3[temp3.prob_L == 0.8250]"
|
| 680 |
+
]
|
| 681 |
+
},
|
| 682 |
+
{
|
| 683 |
+
"cell_type": "code",
|
| 684 |
+
"execution_count": 62,
|
| 685 |
+
"id": "26869713",
|
| 686 |
+
"metadata": {},
|
| 687 |
+
"outputs": [
|
| 688 |
+
{
|
| 689 |
+
"data": {
|
| 690 |
+
"text/plain": [
|
| 691 |
+
"array([0.000e+00, 0.000e+00, 1.030e-02, 1.425e-01, 0.000e+00, 4.113e-01,\n",
|
| 692 |
+
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 6.560e-02,\n",
|
| 693 |
+
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00,\n",
|
| 694 |
+
" 1.000e-03, 0.000e+00, 0.000e+00, 5.857e-01, 0.000e+00, 0.000e+00,\n",
|
| 695 |
+
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 3.471e-01, 0.000e+00,\n",
|
| 696 |
+
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00,\n",
|
| 697 |
+
" 2.000e-04, 0.000e+00, 3.340e-02, 7.391e-01, 7.930e-01, 6.600e-03,\n",
|
| 698 |
+
" 0.000e+00, 0.000e+00, 1.400e-03, 0.000e+00, 0.000e+00, 0.000e+00])"
|
| 699 |
+
]
|
| 700 |
+
},
|
| 701 |
+
"execution_count": 62,
|
| 702 |
+
"metadata": {},
|
| 703 |
+
"output_type": "execute_result"
|
| 704 |
+
}
|
| 705 |
+
],
|
| 706 |
+
"source": [
|
| 707 |
+
"temp3['C'].values.round(4)"
|
| 708 |
+
]
|
| 709 |
+
},
|
| 710 |
+
{
|
| 711 |
+
"cell_type": "code",
|
| 712 |
+
"execution_count": 16,
|
| 713 |
+
"id": "396bf2fb",
|
| 714 |
+
"metadata": {},
|
| 715 |
+
"outputs": [
|
| 716 |
+
{
|
| 717 |
+
"data": {
|
| 718 |
+
"text/html": [
|
| 719 |
+
"<div>\n",
|
| 720 |
+
"<style scoped>\n",
|
| 721 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 722 |
+
" vertical-align: middle;\n",
|
| 723 |
+
" }\n",
|
| 724 |
+
"\n",
|
| 725 |
+
" .dataframe tbody tr th {\n",
|
| 726 |
+
" vertical-align: top;\n",
|
| 727 |
+
" }\n",
|
| 728 |
+
"\n",
|
| 729 |
+
" .dataframe thead th {\n",
|
| 730 |
+
" text-align: right;\n",
|
| 731 |
+
" }\n",
|
| 732 |
+
"</style>\n",
|
| 733 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 734 |
+
" <thead>\n",
|
| 735 |
+
" <tr style=\"text-align: right;\">\n",
|
| 736 |
+
" <th></th>\n",
|
| 737 |
+
" <th>pair_id</th>\n",
|
| 738 |
+
" <th>true_episode</th>\n",
|
| 739 |
+
" </tr>\n",
|
| 740 |
+
" </thead>\n",
|
| 741 |
+
" <tbody>\n",
|
| 742 |
+
" <tr>\n",
|
| 743 |
+
" <th>0</th>\n",
|
| 744 |
+
" <td>Sero-040_4</td>\n",
|
| 745 |
+
" <td>2.0</td>\n",
|
| 746 |
+
" </tr>\n",
|
| 747 |
+
" <tr>\n",
|
| 748 |
+
" <th>7</th>\n",
|
| 749 |
+
" <td>Sero-040_4</td>\n",
|
| 750 |
+
" <td>3.0</td>\n",
|
| 751 |
+
" </tr>\n",
|
| 752 |
+
" </tbody>\n",
|
| 753 |
+
"</table>\n",
|
| 754 |
+
"</div>"
|
| 755 |
+
],
|
| 756 |
+
"text/plain": [
|
| 757 |
+
" pair_id true_episode\n",
|
| 758 |
+
"0 Sero-040_4 2.0\n",
|
| 759 |
+
"7 Sero-040_4 3.0"
|
| 760 |
+
]
|
| 761 |
+
},
|
| 762 |
+
"execution_count": 16,
|
| 763 |
+
"metadata": {},
|
| 764 |
+
"output_type": "execute_result"
|
| 765 |
+
}
|
| 766 |
+
],
|
| 767 |
+
"source": [
|
| 768 |
+
"temp[temp.patient_id == 'Sero-040'][['pair_id', 'true_episode']].drop_duplicates()"
|
| 769 |
+
]
|
| 770 |
+
},
|
| 771 |
+
{
|
| 772 |
+
"cell_type": "code",
|
| 773 |
+
"execution_count": 13,
|
| 774 |
+
"id": "08c5d09b",
|
| 775 |
+
"metadata": {},
|
| 776 |
+
"outputs": [
|
| 777 |
+
{
|
| 778 |
+
"data": {
|
| 779 |
+
"text/plain": [
|
| 780 |
+
"33"
|
| 781 |
+
]
|
| 782 |
+
},
|
| 783 |
+
"execution_count": 13,
|
| 784 |
+
"metadata": {},
|
| 785 |
+
"output_type": "execute_result"
|
| 786 |
+
}
|
| 787 |
+
],
|
| 788 |
+
"source": [
|
| 789 |
+
"temp.patient_id.nunique()"
|
| 790 |
+
]
|
| 791 |
+
},
|
| 792 |
+
{
|
| 793 |
+
"cell_type": "code",
|
| 794 |
+
"execution_count": 14,
|
| 795 |
+
"id": "06ddb7a3",
|
| 796 |
+
"metadata": {},
|
| 797 |
+
"outputs": [
|
| 798 |
+
{
|
| 799 |
+
"data": {
|
| 800 |
+
"text/plain": [
|
| 801 |
+
"47"
|
| 802 |
+
]
|
| 803 |
+
},
|
| 804 |
+
"execution_count": 14,
|
| 805 |
+
"metadata": {},
|
| 806 |
+
"output_type": "execute_result"
|
| 807 |
+
}
|
| 808 |
+
],
|
| 809 |
+
"source": [
|
| 810 |
+
"temp[['patient_id', 'true_episode']].drop_duplicates().shape[0]-33"
|
| 811 |
+
]
|
| 812 |
+
},
|
| 813 |
+
{
|
| 814 |
+
"cell_type": "code",
|
| 815 |
+
"execution_count": 15,
|
| 816 |
+
"id": "65abb261",
|
| 817 |
+
"metadata": {},
|
| 818 |
+
"outputs": [
|
| 819 |
+
{
|
| 820 |
+
"data": {
|
| 821 |
+
"text/html": [
|
| 822 |
+
"<div>\n",
|
| 823 |
+
"<style scoped>\n",
|
| 824 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 825 |
+
" vertical-align: middle;\n",
|
| 826 |
+
" }\n",
|
| 827 |
+
"\n",
|
| 828 |
+
" .dataframe tbody tr th {\n",
|
| 829 |
+
" vertical-align: top;\n",
|
| 830 |
+
" }\n",
|
| 831 |
+
"\n",
|
| 832 |
+
" .dataframe thead th {\n",
|
| 833 |
+
" text-align: right;\n",
|
| 834 |
+
" }\n",
|
| 835 |
+
"</style>\n",
|
| 836 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 837 |
+
" <thead>\n",
|
| 838 |
+
" <tr style=\"text-align: right;\">\n",
|
| 839 |
+
" <th></th>\n",
|
| 840 |
+
" <th>patient_id</th>\n",
|
| 841 |
+
" <th>episode</th>\n",
|
| 842 |
+
" <th>relapse_source_epi</th>\n",
|
| 843 |
+
" <th>C</th>\n",
|
| 844 |
+
" <th>L</th>\n",
|
| 845 |
+
" <th>I</th>\n",
|
| 846 |
+
" </tr>\n",
|
| 847 |
+
" </thead>\n",
|
| 848 |
+
" <tbody>\n",
|
| 849 |
+
" <tr>\n",
|
| 850 |
+
" <th>0</th>\n",
|
| 851 |
+
" <td>Sero-040</td>\n",
|
| 852 |
+
" <td>3</td>\n",
|
| 853 |
+
" <td>1</td>\n",
|
| 854 |
+
" <td>0.0000</td>\n",
|
| 855 |
+
" <td>0.4412</td>\n",
|
| 856 |
+
" <td>0.5588</td>\n",
|
| 857 |
+
" </tr>\n",
|
| 858 |
+
" <tr>\n",
|
| 859 |
+
" <th>1</th>\n",
|
| 860 |
+
" <td>Sero-041</td>\n",
|
| 861 |
+
" <td>2</td>\n",
|
| 862 |
+
" <td>1</td>\n",
|
| 863 |
+
" <td>0.4113</td>\n",
|
| 864 |
+
" <td>0.5611</td>\n",
|
| 865 |
+
" <td>0.0276</td>\n",
|
| 866 |
+
" </tr>\n",
|
| 867 |
+
" <tr>\n",
|
| 868 |
+
" <th>2</th>\n",
|
| 869 |
+
" <td>Sero-041</td>\n",
|
| 870 |
+
" <td>3</td>\n",
|
| 871 |
+
" <td>2</td>\n",
|
| 872 |
+
" <td>0.1759</td>\n",
|
| 873 |
+
" <td>0.7901</td>\n",
|
| 874 |
+
" <td>0.0341</td>\n",
|
| 875 |
+
" </tr>\n",
|
| 876 |
+
" <tr>\n",
|
| 877 |
+
" <th>3</th>\n",
|
| 878 |
+
" <td>Sero-041</td>\n",
|
| 879 |
+
" <td>4</td>\n",
|
| 880 |
+
" <td>1</td>\n",
|
| 881 |
+
" <td>0.0000</td>\n",
|
| 882 |
+
" <td>0.9785</td>\n",
|
| 883 |
+
" <td>0.0215</td>\n",
|
| 884 |
+
" </tr>\n",
|
| 885 |
+
" <tr>\n",
|
| 886 |
+
" <th>4</th>\n",
|
| 887 |
+
" <td>Sero-041</td>\n",
|
| 888 |
+
" <td>5</td>\n",
|
| 889 |
+
" <td>1</td>\n",
|
| 890 |
+
" <td>0.0000</td>\n",
|
| 891 |
+
" <td>0.9785</td>\n",
|
| 892 |
+
" <td>0.0215</td>\n",
|
| 893 |
+
" </tr>\n",
|
| 894 |
+
" <tr>\n",
|
| 895 |
+
" <th>5</th>\n",
|
| 896 |
+
" <td>Sero-041</td>\n",
|
| 897 |
+
" <td>6</td>\n",
|
| 898 |
+
" <td>1</td>\n",
|
| 899 |
+
" <td>0.0000</td>\n",
|
| 900 |
+
" <td>0.1282</td>\n",
|
| 901 |
+
" <td>0.8718</td>\n",
|
| 902 |
+
" </tr>\n",
|
| 903 |
+
" <tr>\n",
|
| 904 |
+
" <th>6</th>\n",
|
| 905 |
+
" <td>Sero-048</td>\n",
|
| 906 |
+
" <td>2</td>\n",
|
| 907 |
+
" <td>1</td>\n",
|
| 908 |
+
" <td>0.0000</td>\n",
|
| 909 |
+
" <td>0.2813</td>\n",
|
| 910 |
+
" <td>0.7187</td>\n",
|
| 911 |
+
" </tr>\n",
|
| 912 |
+
" <tr>\n",
|
| 913 |
+
" <th>7</th>\n",
|
| 914 |
+
" <td>Sero-048</td>\n",
|
| 915 |
+
" <td>3</td>\n",
|
| 916 |
+
" <td>1</td>\n",
|
| 917 |
+
" <td>0.0000</td>\n",
|
| 918 |
+
" <td>0.1603</td>\n",
|
| 919 |
+
" <td>0.8397</td>\n",
|
| 920 |
+
" </tr>\n",
|
| 921 |
+
" <tr>\n",
|
| 922 |
+
" <th>8</th>\n",
|
| 923 |
+
" <td>Sero-048</td>\n",
|
| 924 |
+
" <td>5</td>\n",
|
| 925 |
+
" <td>1</td>\n",
|
| 926 |
+
" <td>0.0000</td>\n",
|
| 927 |
+
" <td>0.1603</td>\n",
|
| 928 |
+
" <td>0.8397</td>\n",
|
| 929 |
+
" </tr>\n",
|
| 930 |
+
" <tr>\n",
|
| 931 |
+
" <th>9</th>\n",
|
| 932 |
+
" <td>Sero-081</td>\n",
|
| 933 |
+
" <td>3</td>\n",
|
| 934 |
+
" <td>1</td>\n",
|
| 935 |
+
" <td>0.0000</td>\n",
|
| 936 |
+
" <td>0.3995</td>\n",
|
| 937 |
+
" <td>0.6005</td>\n",
|
| 938 |
+
" </tr>\n",
|
| 939 |
+
" <tr>\n",
|
| 940 |
+
" <th>10</th>\n",
|
| 941 |
+
" <td>Sero-086</td>\n",
|
| 942 |
+
" <td>2</td>\n",
|
| 943 |
+
" <td>1</td>\n",
|
| 944 |
+
" <td>0.0656</td>\n",
|
| 945 |
+
" <td>0.8952</td>\n",
|
| 946 |
+
" <td>0.0392</td>\n",
|
| 947 |
+
" </tr>\n",
|
| 948 |
+
" <tr>\n",
|
| 949 |
+
" <th>11</th>\n",
|
| 950 |
+
" <td>Sero-103</td>\n",
|
| 951 |
+
" <td>3</td>\n",
|
| 952 |
+
" <td>1</td>\n",
|
| 953 |
+
" <td>0.0000</td>\n",
|
| 954 |
+
" <td>0.1925</td>\n",
|
| 955 |
+
" <td>0.8075</td>\n",
|
| 956 |
+
" </tr>\n",
|
| 957 |
+
" <tr>\n",
|
| 958 |
+
" <th>12</th>\n",
|
| 959 |
+
" <td>Sero-105</td>\n",
|
| 960 |
+
" <td>6</td>\n",
|
| 961 |
+
" <td>1</td>\n",
|
| 962 |
+
" <td>0.0000</td>\n",
|
| 963 |
+
" <td>0.4750</td>\n",
|
| 964 |
+
" <td>0.5250</td>\n",
|
| 965 |
+
" </tr>\n",
|
| 966 |
+
" <tr>\n",
|
| 967 |
+
" <th>13</th>\n",
|
| 968 |
+
" <td>Sero-107</td>\n",
|
| 969 |
+
" <td>4</td>\n",
|
| 970 |
+
" <td>1</td>\n",
|
| 971 |
+
" <td>0.0000</td>\n",
|
| 972 |
+
" <td>0.1009</td>\n",
|
| 973 |
+
" <td>0.8991</td>\n",
|
| 974 |
+
" </tr>\n",
|
| 975 |
+
" <tr>\n",
|
| 976 |
+
" <th>14</th>\n",
|
| 977 |
+
" <td>Sero-109</td>\n",
|
| 978 |
+
" <td>3</td>\n",
|
| 979 |
+
" <td>1</td>\n",
|
| 980 |
+
" <td>0.0000</td>\n",
|
| 981 |
+
" <td>0.7522</td>\n",
|
| 982 |
+
" <td>0.2478</td>\n",
|
| 983 |
+
" </tr>\n",
|
| 984 |
+
" <tr>\n",
|
| 985 |
+
" <th>15</th>\n",
|
| 986 |
+
" <td>Sero-110</td>\n",
|
| 987 |
+
" <td>2</td>\n",
|
| 988 |
+
" <td>1</td>\n",
|
| 989 |
+
" <td>0.0000</td>\n",
|
| 990 |
+
" <td>0.5647</td>\n",
|
| 991 |
+
" <td>0.4353</td>\n",
|
| 992 |
+
" </tr>\n",
|
| 993 |
+
" <tr>\n",
|
| 994 |
+
" <th>16</th>\n",
|
| 995 |
+
" <td>Sero-130</td>\n",
|
| 996 |
+
" <td>2</td>\n",
|
| 997 |
+
" <td>1</td>\n",
|
| 998 |
+
" <td>0.0000</td>\n",
|
| 999 |
+
" <td>0.1440</td>\n",
|
| 1000 |
+
" <td>0.8560</td>\n",
|
| 1001 |
+
" </tr>\n",
|
| 1002 |
+
" <tr>\n",
|
| 1003 |
+
" <th>17</th>\n",
|
| 1004 |
+
" <td>Sero-131</td>\n",
|
| 1005 |
+
" <td>2</td>\n",
|
| 1006 |
+
" <td>1</td>\n",
|
| 1007 |
+
" <td>0.0010</td>\n",
|
| 1008 |
+
" <td>0.9840</td>\n",
|
| 1009 |
+
" <td>0.0150</td>\n",
|
| 1010 |
+
" </tr>\n",
|
| 1011 |
+
" <tr>\n",
|
| 1012 |
+
" <th>18</th>\n",
|
| 1013 |
+
" <td>Sero-131</td>\n",
|
| 1014 |
+
" <td>3</td>\n",
|
| 1015 |
+
" <td>1</td>\n",
|
| 1016 |
+
" <td>0.0000</td>\n",
|
| 1017 |
+
" <td>0.2770</td>\n",
|
| 1018 |
+
" <td>0.7230</td>\n",
|
| 1019 |
+
" </tr>\n",
|
| 1020 |
+
" <tr>\n",
|
| 1021 |
+
" <th>19</th>\n",
|
| 1022 |
+
" <td>Sero-138</td>\n",
|
| 1023 |
+
" <td>5</td>\n",
|
| 1024 |
+
" <td>1</td>\n",
|
| 1025 |
+
" <td>0.0000</td>\n",
|
| 1026 |
+
" <td>0.1460</td>\n",
|
| 1027 |
+
" <td>0.8540</td>\n",
|
| 1028 |
+
" </tr>\n",
|
| 1029 |
+
" <tr>\n",
|
| 1030 |
+
" <th>20</th>\n",
|
| 1031 |
+
" <td>Sero-139</td>\n",
|
| 1032 |
+
" <td>2</td>\n",
|
| 1033 |
+
" <td>1</td>\n",
|
| 1034 |
+
" <td>0.5857</td>\n",
|
| 1035 |
+
" <td>0.3897</td>\n",
|
| 1036 |
+
" <td>0.0246</td>\n",
|
| 1037 |
+
" </tr>\n",
|
| 1038 |
+
" <tr>\n",
|
| 1039 |
+
" <th>21</th>\n",
|
| 1040 |
+
" <td>Sero-142</td>\n",
|
| 1041 |
+
" <td>2</td>\n",
|
| 1042 |
+
" <td>1</td>\n",
|
| 1043 |
+
" <td>0.0000</td>\n",
|
| 1044 |
+
" <td>0.3768</td>\n",
|
| 1045 |
+
" <td>0.6232</td>\n",
|
| 1046 |
+
" </tr>\n",
|
| 1047 |
+
" <tr>\n",
|
| 1048 |
+
" <th>22</th>\n",
|
| 1049 |
+
" <td>Sero-142</td>\n",
|
| 1050 |
+
" <td>3</td>\n",
|
| 1051 |
+
" <td>1</td>\n",
|
| 1052 |
+
" <td>0.0000</td>\n",
|
| 1053 |
+
" <td>0.1754</td>\n",
|
| 1054 |
+
" <td>0.8246</td>\n",
|
| 1055 |
+
" </tr>\n",
|
| 1056 |
+
" <tr>\n",
|
| 1057 |
+
" <th>23</th>\n",
|
| 1058 |
+
" <td>Sero-148</td>\n",
|
| 1059 |
+
" <td>3</td>\n",
|
| 1060 |
+
" <td>1</td>\n",
|
| 1061 |
+
" <td>0.0000</td>\n",
|
| 1062 |
+
" <td>0.1023</td>\n",
|
| 1063 |
+
" <td>0.8977</td>\n",
|
| 1064 |
+
" </tr>\n",
|
| 1065 |
+
" <tr>\n",
|
| 1066 |
+
" <th>24</th>\n",
|
| 1067 |
+
" <td>Sero-154</td>\n",
|
| 1068 |
+
" <td>2</td>\n",
|
| 1069 |
+
" <td>1</td>\n",
|
| 1070 |
+
" <td>0.0000</td>\n",
|
| 1071 |
+
" <td>0.9993</td>\n",
|
| 1072 |
+
" <td>0.0007</td>\n",
|
| 1073 |
+
" </tr>\n",
|
| 1074 |
+
" <tr>\n",
|
| 1075 |
+
" <th>25</th>\n",
|
| 1076 |
+
" <td>Sero-161</td>\n",
|
| 1077 |
+
" <td>2</td>\n",
|
| 1078 |
+
" <td>1</td>\n",
|
| 1079 |
+
" <td>0.0000</td>\n",
|
| 1080 |
+
" <td>0.9723</td>\n",
|
| 1081 |
+
" <td>0.0277</td>\n",
|
| 1082 |
+
" </tr>\n",
|
| 1083 |
+
" <tr>\n",
|
| 1084 |
+
" <th>26</th>\n",
|
| 1085 |
+
" <td>Sero-161</td>\n",
|
| 1086 |
+
" <td>3</td>\n",
|
| 1087 |
+
" <td>2</td>\n",
|
| 1088 |
+
" <td>0.3471</td>\n",
|
| 1089 |
+
" <td>0.6463</td>\n",
|
| 1090 |
+
" <td>0.0066</td>\n",
|
| 1091 |
+
" </tr>\n",
|
| 1092 |
+
" <tr>\n",
|
| 1093 |
+
" <th>27</th>\n",
|
| 1094 |
+
" <td>Sero-161</td>\n",
|
| 1095 |
+
" <td>4</td>\n",
|
| 1096 |
+
" <td>1</td>\n",
|
| 1097 |
+
" <td>0.0000</td>\n",
|
| 1098 |
+
" <td>0.9899</td>\n",
|
| 1099 |
+
" <td>0.0101</td>\n",
|
| 1100 |
+
" </tr>\n",
|
| 1101 |
+
" <tr>\n",
|
| 1102 |
+
" <th>28</th>\n",
|
| 1103 |
+
" <td>Sero-182</td>\n",
|
| 1104 |
+
" <td>3</td>\n",
|
| 1105 |
+
" <td>1</td>\n",
|
| 1106 |
+
" <td>0.0000</td>\n",
|
| 1107 |
+
" <td>0.0935</td>\n",
|
| 1108 |
+
" <td>0.9065</td>\n",
|
| 1109 |
+
" </tr>\n",
|
| 1110 |
+
" <tr>\n",
|
| 1111 |
+
" <th>29</th>\n",
|
| 1112 |
+
" <td>Sero-194</td>\n",
|
| 1113 |
+
" <td>3</td>\n",
|
| 1114 |
+
" <td>1</td>\n",
|
| 1115 |
+
" <td>0.0000</td>\n",
|
| 1116 |
+
" <td>0.0681</td>\n",
|
| 1117 |
+
" <td>0.9319</td>\n",
|
| 1118 |
+
" </tr>\n",
|
| 1119 |
+
" <tr>\n",
|
| 1120 |
+
" <th>30</th>\n",
|
| 1121 |
+
" <td>Sero-194</td>\n",
|
| 1122 |
+
" <td>4</td>\n",
|
| 1123 |
+
" <td>1</td>\n",
|
| 1124 |
+
" <td>0.0000</td>\n",
|
| 1125 |
+
" <td>0.0930</td>\n",
|
| 1126 |
+
" <td>0.9070</td>\n",
|
| 1127 |
+
" </tr>\n",
|
| 1128 |
+
" <tr>\n",
|
| 1129 |
+
" <th>31</th>\n",
|
| 1130 |
+
" <td>Sero-195</td>\n",
|
| 1131 |
+
" <td>3</td>\n",
|
| 1132 |
+
" <td>1</td>\n",
|
| 1133 |
+
" <td>0.0000</td>\n",
|
| 1134 |
+
" <td>0.0949</td>\n",
|
| 1135 |
+
" <td>0.9051</td>\n",
|
| 1136 |
+
" </tr>\n",
|
| 1137 |
+
" <tr>\n",
|
| 1138 |
+
" <th>32</th>\n",
|
| 1139 |
+
" <td>Sero-215</td>\n",
|
| 1140 |
+
" <td>2</td>\n",
|
| 1141 |
+
" <td>1</td>\n",
|
| 1142 |
+
" <td>0.0000</td>\n",
|
| 1143 |
+
" <td>0.1731</td>\n",
|
| 1144 |
+
" <td>0.8269</td>\n",
|
| 1145 |
+
" </tr>\n",
|
| 1146 |
+
" <tr>\n",
|
| 1147 |
+
" <th>33</th>\n",
|
| 1148 |
+
" <td>Sero-218</td>\n",
|
| 1149 |
+
" <td>2</td>\n",
|
| 1150 |
+
" <td>1</td>\n",
|
| 1151 |
+
" <td>0.0000</td>\n",
|
| 1152 |
+
" <td>0.4813</td>\n",
|
| 1153 |
+
" <td>0.5187</td>\n",
|
| 1154 |
+
" </tr>\n",
|
| 1155 |
+
" <tr>\n",
|
| 1156 |
+
" <th>34</th>\n",
|
| 1157 |
+
" <td>Sero-226</td>\n",
|
| 1158 |
+
" <td>3</td>\n",
|
| 1159 |
+
" <td>1</td>\n",
|
| 1160 |
+
" <td>0.0000</td>\n",
|
| 1161 |
+
" <td>0.1585</td>\n",
|
| 1162 |
+
" <td>0.8415</td>\n",
|
| 1163 |
+
" </tr>\n",
|
| 1164 |
+
" <tr>\n",
|
| 1165 |
+
" <th>35</th>\n",
|
| 1166 |
+
" <td>Sero-229</td>\n",
|
| 1167 |
+
" <td>2</td>\n",
|
| 1168 |
+
" <td>1</td>\n",
|
| 1169 |
+
" <td>0.0002</td>\n",
|
| 1170 |
+
" <td>0.9990</td>\n",
|
| 1171 |
+
" <td>0.0008</td>\n",
|
| 1172 |
+
" </tr>\n",
|
| 1173 |
+
" <tr>\n",
|
| 1174 |
+
" <th>36</th>\n",
|
| 1175 |
+
" <td>Sero-230</td>\n",
|
| 1176 |
+
" <td>3</td>\n",
|
| 1177 |
+
" <td>1</td>\n",
|
| 1178 |
+
" <td>0.0000</td>\n",
|
| 1179 |
+
" <td>0.4955</td>\n",
|
| 1180 |
+
" <td>0.5045</td>\n",
|
| 1181 |
+
" </tr>\n",
|
| 1182 |
+
" <tr>\n",
|
| 1183 |
+
" <th>37</th>\n",
|
| 1184 |
+
" <td>Sero-232</td>\n",
|
| 1185 |
+
" <td>2</td>\n",
|
| 1186 |
+
" <td>1</td>\n",
|
| 1187 |
+
" <td>0.7391</td>\n",
|
| 1188 |
+
" <td>0.2608</td>\n",
|
| 1189 |
+
" <td>0.0001</td>\n",
|
| 1190 |
+
" </tr>\n",
|
| 1191 |
+
" <tr>\n",
|
| 1192 |
+
" <th>38</th>\n",
|
| 1193 |
+
" <td>Sero-232</td>\n",
|
| 1194 |
+
" <td>3</td>\n",
|
| 1195 |
+
" <td>2</td>\n",
|
| 1196 |
+
" <td>0.7930</td>\n",
|
| 1197 |
+
" <td>0.2069</td>\n",
|
| 1198 |
+
" <td>0.0001</td>\n",
|
| 1199 |
+
" </tr>\n",
|
| 1200 |
+
" <tr>\n",
|
| 1201 |
+
" <th>39</th>\n",
|
| 1202 |
+
" <td>Sero-232</td>\n",
|
| 1203 |
+
" <td>4</td>\n",
|
| 1204 |
+
" <td>1</td>\n",
|
| 1205 |
+
" <td>0.0000</td>\n",
|
| 1206 |
+
" <td>0.9999</td>\n",
|
| 1207 |
+
" <td>0.0001</td>\n",
|
| 1208 |
+
" </tr>\n",
|
| 1209 |
+
" <tr>\n",
|
| 1210 |
+
" <th>40</th>\n",
|
| 1211 |
+
" <td>Sero-242</td>\n",
|
| 1212 |
+
" <td>2</td>\n",
|
| 1213 |
+
" <td>1</td>\n",
|
| 1214 |
+
" <td>0.0066</td>\n",
|
| 1215 |
+
" <td>0.9889</td>\n",
|
| 1216 |
+
" <td>0.0045</td>\n",
|
| 1217 |
+
" </tr>\n",
|
| 1218 |
+
" <tr>\n",
|
| 1219 |
+
" <th>41</th>\n",
|
| 1220 |
+
" <td>Sero-244</td>\n",
|
| 1221 |
+
" <td>2</td>\n",
|
| 1222 |
+
" <td>1</td>\n",
|
| 1223 |
+
" <td>0.0000</td>\n",
|
| 1224 |
+
" <td>0.1184</td>\n",
|
| 1225 |
+
" <td>0.8816</td>\n",
|
| 1226 |
+
" </tr>\n",
|
| 1227 |
+
" <tr>\n",
|
| 1228 |
+
" <th>42</th>\n",
|
| 1229 |
+
" <td>Sero-256</td>\n",
|
| 1230 |
+
" <td>2</td>\n",
|
| 1231 |
+
" <td>1</td>\n",
|
| 1232 |
+
" <td>0.0000</td>\n",
|
| 1233 |
+
" <td>0.3498</td>\n",
|
| 1234 |
+
" <td>0.6502</td>\n",
|
| 1235 |
+
" </tr>\n",
|
| 1236 |
+
" <tr>\n",
|
| 1237 |
+
" <th>43</th>\n",
|
| 1238 |
+
" <td>Sero-258</td>\n",
|
| 1239 |
+
" <td>3</td>\n",
|
| 1240 |
+
" <td>1</td>\n",
|
| 1241 |
+
" <td>0.0000</td>\n",
|
| 1242 |
+
" <td>0.8536</td>\n",
|
| 1243 |
+
" <td>0.1464</td>\n",
|
| 1244 |
+
" </tr>\n",
|
| 1245 |
+
" <tr>\n",
|
| 1246 |
+
" <th>44</th>\n",
|
| 1247 |
+
" <td>Sero-258</td>\n",
|
| 1248 |
+
" <td>4</td>\n",
|
| 1249 |
+
" <td>1</td>\n",
|
| 1250 |
+
" <td>0.0000</td>\n",
|
| 1251 |
+
" <td>0.9372</td>\n",
|
| 1252 |
+
" <td>0.0628</td>\n",
|
| 1253 |
+
" </tr>\n",
|
| 1254 |
+
" <tr>\n",
|
| 1255 |
+
" <th>45</th>\n",
|
| 1256 |
+
" <td>Sero-267</td>\n",
|
| 1257 |
+
" <td>2</td>\n",
|
| 1258 |
+
" <td>1</td>\n",
|
| 1259 |
+
" <td>0.0000</td>\n",
|
| 1260 |
+
" <td>0.7976</td>\n",
|
| 1261 |
+
" <td>0.2024</td>\n",
|
| 1262 |
+
" </tr>\n",
|
| 1263 |
+
" <tr>\n",
|
| 1264 |
+
" <th>46</th>\n",
|
| 1265 |
+
" <td>Sero-277</td>\n",
|
| 1266 |
+
" <td>2</td>\n",
|
| 1267 |
+
" <td>1</td>\n",
|
| 1268 |
+
" <td>0.0000</td>\n",
|
| 1269 |
+
" <td>0.9551</td>\n",
|
| 1270 |
+
" <td>0.0449</td>\n",
|
| 1271 |
+
" </tr>\n",
|
| 1272 |
+
" </tbody>\n",
|
| 1273 |
+
"</table>\n",
|
| 1274 |
+
"</div>"
|
| 1275 |
+
],
|
| 1276 |
+
"text/plain": [
|
| 1277 |
+
" patient_id episode relapse_source_epi C L I\n",
|
| 1278 |
+
"0 Sero-040 3 1 0.0000 0.4412 0.5588\n",
|
| 1279 |
+
"1 Sero-041 2 1 0.4113 0.5611 0.0276\n",
|
| 1280 |
+
"2 Sero-041 3 2 0.1759 0.7901 0.0341\n",
|
| 1281 |
+
"3 Sero-041 4 1 0.0000 0.9785 0.0215\n",
|
| 1282 |
+
"4 Sero-041 5 1 0.0000 0.9785 0.0215\n",
|
| 1283 |
+
"5 Sero-041 6 1 0.0000 0.1282 0.8718\n",
|
| 1284 |
+
"6 Sero-048 2 1 0.0000 0.2813 0.7187\n",
|
| 1285 |
+
"7 Sero-048 3 1 0.0000 0.1603 0.8397\n",
|
| 1286 |
+
"8 Sero-048 5 1 0.0000 0.1603 0.8397\n",
|
| 1287 |
+
"9 Sero-081 3 1 0.0000 0.3995 0.6005\n",
|
| 1288 |
+
"10 Sero-086 2 1 0.0656 0.8952 0.0392\n",
|
| 1289 |
+
"11 Sero-103 3 1 0.0000 0.1925 0.8075\n",
|
| 1290 |
+
"12 Sero-105 6 1 0.0000 0.4750 0.5250\n",
|
| 1291 |
+
"13 Sero-107 4 1 0.0000 0.1009 0.8991\n",
|
| 1292 |
+
"14 Sero-109 3 1 0.0000 0.7522 0.2478\n",
|
| 1293 |
+
"15 Sero-110 2 1 0.0000 0.5647 0.4353\n",
|
| 1294 |
+
"16 Sero-130 2 1 0.0000 0.1440 0.8560\n",
|
| 1295 |
+
"17 Sero-131 2 1 0.0010 0.9840 0.0150\n",
|
| 1296 |
+
"18 Sero-131 3 1 0.0000 0.2770 0.7230\n",
|
| 1297 |
+
"19 Sero-138 5 1 0.0000 0.1460 0.8540\n",
|
| 1298 |
+
"20 Sero-139 2 1 0.5857 0.3897 0.0246\n",
|
| 1299 |
+
"21 Sero-142 2 1 0.0000 0.3768 0.6232\n",
|
| 1300 |
+
"22 Sero-142 3 1 0.0000 0.1754 0.8246\n",
|
| 1301 |
+
"23 Sero-148 3 1 0.0000 0.1023 0.8977\n",
|
| 1302 |
+
"24 Sero-154 2 1 0.0000 0.9993 0.0007\n",
|
| 1303 |
+
"25 Sero-161 2 1 0.0000 0.9723 0.0277\n",
|
| 1304 |
+
"26 Sero-161 3 2 0.3471 0.6463 0.0066\n",
|
| 1305 |
+
"27 Sero-161 4 1 0.0000 0.9899 0.0101\n",
|
| 1306 |
+
"28 Sero-182 3 1 0.0000 0.0935 0.9065\n",
|
| 1307 |
+
"29 Sero-194 3 1 0.0000 0.0681 0.9319\n",
|
| 1308 |
+
"30 Sero-194 4 1 0.0000 0.0930 0.9070\n",
|
| 1309 |
+
"31 Sero-195 3 1 0.0000 0.0949 0.9051\n",
|
| 1310 |
+
"32 Sero-215 2 1 0.0000 0.1731 0.8269\n",
|
| 1311 |
+
"33 Sero-218 2 1 0.0000 0.4813 0.5187\n",
|
| 1312 |
+
"34 Sero-226 3 1 0.0000 0.1585 0.8415\n",
|
| 1313 |
+
"35 Sero-229 2 1 0.0002 0.9990 0.0008\n",
|
| 1314 |
+
"36 Sero-230 3 1 0.0000 0.4955 0.5045\n",
|
| 1315 |
+
"37 Sero-232 2 1 0.7391 0.2608 0.0001\n",
|
| 1316 |
+
"38 Sero-232 3 2 0.7930 0.2069 0.0001\n",
|
| 1317 |
+
"39 Sero-232 4 1 0.0000 0.9999 0.0001\n",
|
| 1318 |
+
"40 Sero-242 2 1 0.0066 0.9889 0.0045\n",
|
| 1319 |
+
"41 Sero-244 2 1 0.0000 0.1184 0.8816\n",
|
| 1320 |
+
"42 Sero-256 2 1 0.0000 0.3498 0.6502\n",
|
| 1321 |
+
"43 Sero-258 3 1 0.0000 0.8536 0.1464\n",
|
| 1322 |
+
"44 Sero-258 4 1 0.0000 0.9372 0.0628\n",
|
| 1323 |
+
"45 Sero-267 2 1 0.0000 0.7976 0.2024\n",
|
| 1324 |
+
"46 Sero-277 2 1 0.0000 0.9551 0.0449"
|
| 1325 |
+
]
|
| 1326 |
+
},
|
| 1327 |
+
"execution_count": 15,
|
| 1328 |
+
"metadata": {},
|
| 1329 |
+
"output_type": "execute_result"
|
| 1330 |
+
}
|
| 1331 |
+
],
|
| 1332 |
+
"source": [
|
| 1333 |
+
"temp3"
|
| 1334 |
+
]
|
| 1335 |
+
},
|
| 1336 |
+
{
|
| 1337 |
+
"cell_type": "code",
|
| 1338 |
+
"execution_count": null,
|
| 1339 |
+
"id": "bd2dc041",
|
| 1340 |
+
"metadata": {},
|
| 1341 |
+
"outputs": [
|
| 1342 |
+
{
|
| 1343 |
+
"data": {
|
| 1344 |
+
"text/html": [
|
| 1345 |
+
"<div>\n",
|
| 1346 |
+
"<style scoped>\n",
|
| 1347 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1348 |
+
" vertical-align: middle;\n",
|
| 1349 |
+
" }\n",
|
| 1350 |
+
"\n",
|
| 1351 |
+
" .dataframe tbody tr th {\n",
|
| 1352 |
+
" vertical-align: top;\n",
|
| 1353 |
+
" }\n",
|
| 1354 |
+
"\n",
|
| 1355 |
+
" .dataframe thead th {\n",
|
| 1356 |
+
" text-align: right;\n",
|
| 1357 |
+
" }\n",
|
| 1358 |
+
"</style>\n",
|
| 1359 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1360 |
+
" <thead>\n",
|
| 1361 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1362 |
+
" <th></th>\n",
|
| 1363 |
+
" <th>C</th>\n",
|
| 1364 |
+
" <th>L</th>\n",
|
| 1365 |
+
" <th>I</th>\n",
|
| 1366 |
+
" </tr>\n",
|
| 1367 |
+
" </thead>\n",
|
| 1368 |
+
" <tbody>\n",
|
| 1369 |
+
" <tr>\n",
|
| 1370 |
+
" <th>0</th>\n",
|
| 1371 |
+
" <td>0.0000</td>\n",
|
| 1372 |
+
" <td>0.4412</td>\n",
|
| 1373 |
+
" <td>0.5588</td>\n",
|
| 1374 |
+
" </tr>\n",
|
| 1375 |
+
" <tr>\n",
|
| 1376 |
+
" <th>1</th>\n",
|
| 1377 |
+
" <td>0.0000</td>\n",
|
| 1378 |
+
" <td>0.1282</td>\n",
|
| 1379 |
+
" <td>0.8718</td>\n",
|
| 1380 |
+
" </tr>\n",
|
| 1381 |
+
" <tr>\n",
|
| 1382 |
+
" <th>2</th>\n",
|
| 1383 |
+
" <td>0.0103</td>\n",
|
| 1384 |
+
" <td>0.9684</td>\n",
|
| 1385 |
+
" <td>0.0213</td>\n",
|
| 1386 |
+
" </tr>\n",
|
| 1387 |
+
" <tr>\n",
|
| 1388 |
+
" <th>3</th>\n",
|
| 1389 |
+
" <td>0.1425</td>\n",
|
| 1390 |
+
" <td>0.6402</td>\n",
|
| 1391 |
+
" <td>0.2173</td>\n",
|
| 1392 |
+
" </tr>\n",
|
| 1393 |
+
" <tr>\n",
|
| 1394 |
+
" <th>4</th>\n",
|
| 1395 |
+
" <td>0.0000</td>\n",
|
| 1396 |
+
" <td>0.4368</td>\n",
|
| 1397 |
+
" <td>0.5632</td>\n",
|
| 1398 |
+
" </tr>\n",
|
| 1399 |
+
" <tr>\n",
|
| 1400 |
+
" <th>5</th>\n",
|
| 1401 |
+
" <td>0.4113</td>\n",
|
| 1402 |
+
" <td>0.5611</td>\n",
|
| 1403 |
+
" <td>0.0276</td>\n",
|
| 1404 |
+
" </tr>\n",
|
| 1405 |
+
" <tr>\n",
|
| 1406 |
+
" <th>6</th>\n",
|
| 1407 |
+
" <td>0.0000</td>\n",
|
| 1408 |
+
" <td>0.0833</td>\n",
|
| 1409 |
+
" <td>0.9167</td>\n",
|
| 1410 |
+
" </tr>\n",
|
| 1411 |
+
" <tr>\n",
|
| 1412 |
+
" <th>7</th>\n",
|
| 1413 |
+
" <td>0.0000</td>\n",
|
| 1414 |
+
" <td>0.1084</td>\n",
|
| 1415 |
+
" <td>0.8916</td>\n",
|
| 1416 |
+
" </tr>\n",
|
| 1417 |
+
" <tr>\n",
|
| 1418 |
+
" <th>8</th>\n",
|
| 1419 |
+
" <td>0.0000</td>\n",
|
| 1420 |
+
" <td>0.2813</td>\n",
|
| 1421 |
+
" <td>0.7187</td>\n",
|
| 1422 |
+
" </tr>\n",
|
| 1423 |
+
" <tr>\n",
|
| 1424 |
+
" <th>9</th>\n",
|
| 1425 |
+
" <td>0.0000</td>\n",
|
| 1426 |
+
" <td>0.1603</td>\n",
|
| 1427 |
+
" <td>0.8397</td>\n",
|
| 1428 |
+
" </tr>\n",
|
| 1429 |
+
" <tr>\n",
|
| 1430 |
+
" <th>10</th>\n",
|
| 1431 |
+
" <td>0.0000</td>\n",
|
| 1432 |
+
" <td>0.3995</td>\n",
|
| 1433 |
+
" <td>0.6005</td>\n",
|
| 1434 |
+
" </tr>\n",
|
| 1435 |
+
" <tr>\n",
|
| 1436 |
+
" <th>11</th>\n",
|
| 1437 |
+
" <td>0.0656</td>\n",
|
| 1438 |
+
" <td>0.8952</td>\n",
|
| 1439 |
+
" <td>0.0392</td>\n",
|
| 1440 |
+
" </tr>\n",
|
| 1441 |
+
" <tr>\n",
|
| 1442 |
+
" <th>12</th>\n",
|
| 1443 |
+
" <td>0.0000</td>\n",
|
| 1444 |
+
" <td>0.1925</td>\n",
|
| 1445 |
+
" <td>0.8075</td>\n",
|
| 1446 |
+
" </tr>\n",
|
| 1447 |
+
" <tr>\n",
|
| 1448 |
+
" <th>13</th>\n",
|
| 1449 |
+
" <td>0.0000</td>\n",
|
| 1450 |
+
" <td>0.4750</td>\n",
|
| 1451 |
+
" <td>0.5250</td>\n",
|
| 1452 |
+
" </tr>\n",
|
| 1453 |
+
" <tr>\n",
|
| 1454 |
+
" <th>14</th>\n",
|
| 1455 |
+
" <td>0.0000</td>\n",
|
| 1456 |
+
" <td>0.1009</td>\n",
|
| 1457 |
+
" <td>0.8991</td>\n",
|
| 1458 |
+
" </tr>\n",
|
| 1459 |
+
" <tr>\n",
|
| 1460 |
+
" <th>15</th>\n",
|
| 1461 |
+
" <td>0.0000</td>\n",
|
| 1462 |
+
" <td>0.7522</td>\n",
|
| 1463 |
+
" <td>0.2478</td>\n",
|
| 1464 |
+
" </tr>\n",
|
| 1465 |
+
" <tr>\n",
|
| 1466 |
+
" <th>16</th>\n",
|
| 1467 |
+
" <td>0.0000</td>\n",
|
| 1468 |
+
" <td>0.5647</td>\n",
|
| 1469 |
+
" <td>0.4353</td>\n",
|
| 1470 |
+
" </tr>\n",
|
| 1471 |
+
" <tr>\n",
|
| 1472 |
+
" <th>17</th>\n",
|
| 1473 |
+
" <td>0.0000</td>\n",
|
| 1474 |
+
" <td>0.1440</td>\n",
|
| 1475 |
+
" <td>0.8560</td>\n",
|
| 1476 |
+
" </tr>\n",
|
| 1477 |
+
" <tr>\n",
|
| 1478 |
+
" <th>18</th>\n",
|
| 1479 |
+
" <td>0.0010</td>\n",
|
| 1480 |
+
" <td>0.9841</td>\n",
|
| 1481 |
+
" <td>0.0150</td>\n",
|
| 1482 |
+
" </tr>\n",
|
| 1483 |
+
" <tr>\n",
|
| 1484 |
+
" <th>19</th>\n",
|
| 1485 |
+
" <td>0.0000</td>\n",
|
| 1486 |
+
" <td>0.2770</td>\n",
|
| 1487 |
+
" <td>0.7230</td>\n",
|
| 1488 |
+
" </tr>\n",
|
| 1489 |
+
" <tr>\n",
|
| 1490 |
+
" <th>20</th>\n",
|
| 1491 |
+
" <td>0.0000</td>\n",
|
| 1492 |
+
" <td>0.1460</td>\n",
|
| 1493 |
+
" <td>0.8540</td>\n",
|
| 1494 |
+
" </tr>\n",
|
| 1495 |
+
" <tr>\n",
|
| 1496 |
+
" <th>21</th>\n",
|
| 1497 |
+
" <td>0.5857</td>\n",
|
| 1498 |
+
" <td>0.3897</td>\n",
|
| 1499 |
+
" <td>0.0246</td>\n",
|
| 1500 |
+
" </tr>\n",
|
| 1501 |
+
" <tr>\n",
|
| 1502 |
+
" <th>22</th>\n",
|
| 1503 |
+
" <td>0.0000</td>\n",
|
| 1504 |
+
" <td>0.3768</td>\n",
|
| 1505 |
+
" <td>0.6232</td>\n",
|
| 1506 |
+
" </tr>\n",
|
| 1507 |
+
" <tr>\n",
|
| 1508 |
+
" <th>23</th>\n",
|
| 1509 |
+
" <td>0.0000</td>\n",
|
| 1510 |
+
" <td>0.1754</td>\n",
|
| 1511 |
+
" <td>0.8246</td>\n",
|
| 1512 |
+
" </tr>\n",
|
| 1513 |
+
" <tr>\n",
|
| 1514 |
+
" <th>24</th>\n",
|
| 1515 |
+
" <td>0.0000</td>\n",
|
| 1516 |
+
" <td>0.1023</td>\n",
|
| 1517 |
+
" <td>0.8977</td>\n",
|
| 1518 |
+
" </tr>\n",
|
| 1519 |
+
" <tr>\n",
|
| 1520 |
+
" <th>25</th>\n",
|
| 1521 |
+
" <td>0.0000</td>\n",
|
| 1522 |
+
" <td>0.9993</td>\n",
|
| 1523 |
+
" <td>0.0007</td>\n",
|
| 1524 |
+
" </tr>\n",
|
| 1525 |
+
" <tr>\n",
|
| 1526 |
+
" <th>26</th>\n",
|
| 1527 |
+
" <td>0.0000</td>\n",
|
| 1528 |
+
" <td>0.9722</td>\n",
|
| 1529 |
+
" <td>0.0277</td>\n",
|
| 1530 |
+
" </tr>\n",
|
| 1531 |
+
" <tr>\n",
|
| 1532 |
+
" <th>27</th>\n",
|
| 1533 |
+
" <td>0.0000</td>\n",
|
| 1534 |
+
" <td>0.1487</td>\n",
|
| 1535 |
+
" <td>0.8513</td>\n",
|
| 1536 |
+
" </tr>\n",
|
| 1537 |
+
" <tr>\n",
|
| 1538 |
+
" <th>28</th>\n",
|
| 1539 |
+
" <td>0.3471</td>\n",
|
| 1540 |
+
" <td>0.6463</td>\n",
|
| 1541 |
+
" <td>0.0066</td>\n",
|
| 1542 |
+
" </tr>\n",
|
| 1543 |
+
" <tr>\n",
|
| 1544 |
+
" <th>29</th>\n",
|
| 1545 |
+
" <td>0.0000</td>\n",
|
| 1546 |
+
" <td>0.0935</td>\n",
|
| 1547 |
+
" <td>0.9065</td>\n",
|
| 1548 |
+
" </tr>\n",
|
| 1549 |
+
" <tr>\n",
|
| 1550 |
+
" <th>30</th>\n",
|
| 1551 |
+
" <td>0.0000</td>\n",
|
| 1552 |
+
" <td>0.0681</td>\n",
|
| 1553 |
+
" <td>0.9319</td>\n",
|
| 1554 |
+
" </tr>\n",
|
| 1555 |
+
" <tr>\n",
|
| 1556 |
+
" <th>31</th>\n",
|
| 1557 |
+
" <td>0.0000</td>\n",
|
| 1558 |
+
" <td>0.0930</td>\n",
|
| 1559 |
+
" <td>0.9070</td>\n",
|
| 1560 |
+
" </tr>\n",
|
| 1561 |
+
" <tr>\n",
|
| 1562 |
+
" <th>32</th>\n",
|
| 1563 |
+
" <td>0.0000</td>\n",
|
| 1564 |
+
" <td>0.0949</td>\n",
|
| 1565 |
+
" <td>0.9051</td>\n",
|
| 1566 |
+
" </tr>\n",
|
| 1567 |
+
" <tr>\n",
|
| 1568 |
+
" <th>33</th>\n",
|
| 1569 |
+
" <td>0.0000</td>\n",
|
| 1570 |
+
" <td>0.1731</td>\n",
|
| 1571 |
+
" <td>0.8269</td>\n",
|
| 1572 |
+
" </tr>\n",
|
| 1573 |
+
" <tr>\n",
|
| 1574 |
+
" <th>34</th>\n",
|
| 1575 |
+
" <td>0.0000</td>\n",
|
| 1576 |
+
" <td>0.4813</td>\n",
|
| 1577 |
+
" <td>0.5187</td>\n",
|
| 1578 |
+
" </tr>\n",
|
| 1579 |
+
" <tr>\n",
|
| 1580 |
+
" <th>35</th>\n",
|
| 1581 |
+
" <td>0.0000</td>\n",
|
| 1582 |
+
" <td>0.1585</td>\n",
|
| 1583 |
+
" <td>0.8415</td>\n",
|
| 1584 |
+
" </tr>\n",
|
| 1585 |
+
" <tr>\n",
|
| 1586 |
+
" <th>36</th>\n",
|
| 1587 |
+
" <td>0.0002</td>\n",
|
| 1588 |
+
" <td>0.9989</td>\n",
|
| 1589 |
+
" <td>0.0008</td>\n",
|
| 1590 |
+
" </tr>\n",
|
| 1591 |
+
" <tr>\n",
|
| 1592 |
+
" <th>37</th>\n",
|
| 1593 |
+
" <td>0.0000</td>\n",
|
| 1594 |
+
" <td>0.4955</td>\n",
|
| 1595 |
+
" <td>0.5045</td>\n",
|
| 1596 |
+
" </tr>\n",
|
| 1597 |
+
" <tr>\n",
|
| 1598 |
+
" <th>38</th>\n",
|
| 1599 |
+
" <td>0.0334</td>\n",
|
| 1600 |
+
" <td>0.9617</td>\n",
|
| 1601 |
+
" <td>0.0049</td>\n",
|
| 1602 |
+
" </tr>\n",
|
| 1603 |
+
" <tr>\n",
|
| 1604 |
+
" <th>39</th>\n",
|
| 1605 |
+
" <td>0.7391</td>\n",
|
| 1606 |
+
" <td>0.2608</td>\n",
|
| 1607 |
+
" <td>0.0001</td>\n",
|
| 1608 |
+
" </tr>\n",
|
| 1609 |
+
" <tr>\n",
|
| 1610 |
+
" <th>40</th>\n",
|
| 1611 |
+
" <td>0.7930</td>\n",
|
| 1612 |
+
" <td>0.2069</td>\n",
|
| 1613 |
+
" <td>0.0001</td>\n",
|
| 1614 |
+
" </tr>\n",
|
| 1615 |
+
" <tr>\n",
|
| 1616 |
+
" <th>41</th>\n",
|
| 1617 |
+
" <td>0.0066</td>\n",
|
| 1618 |
+
" <td>0.9888</td>\n",
|
| 1619 |
+
" <td>0.0045</td>\n",
|
| 1620 |
+
" </tr>\n",
|
| 1621 |
+
" <tr>\n",
|
| 1622 |
+
" <th>42</th>\n",
|
| 1623 |
+
" <td>0.0000</td>\n",
|
| 1624 |
+
" <td>0.1184</td>\n",
|
| 1625 |
+
" <td>0.8816</td>\n",
|
| 1626 |
+
" </tr>\n",
|
| 1627 |
+
" <tr>\n",
|
| 1628 |
+
" <th>43</th>\n",
|
| 1629 |
+
" <td>0.0000</td>\n",
|
| 1630 |
+
" <td>0.3498</td>\n",
|
| 1631 |
+
" <td>0.6502</td>\n",
|
| 1632 |
+
" </tr>\n",
|
| 1633 |
+
" <tr>\n",
|
| 1634 |
+
" <th>44</th>\n",
|
| 1635 |
+
" <td>0.0014</td>\n",
|
| 1636 |
+
" <td>0.9359</td>\n",
|
| 1637 |
+
" <td>0.0627</td>\n",
|
| 1638 |
+
" </tr>\n",
|
| 1639 |
+
" <tr>\n",
|
| 1640 |
+
" <th>45</th>\n",
|
| 1641 |
+
" <td>0.0000</td>\n",
|
| 1642 |
+
" <td>0.8535</td>\n",
|
| 1643 |
+
" <td>0.1464</td>\n",
|
| 1644 |
+
" </tr>\n",
|
| 1645 |
+
" <tr>\n",
|
| 1646 |
+
" <th>46</th>\n",
|
| 1647 |
+
" <td>0.0000</td>\n",
|
| 1648 |
+
" <td>0.7976</td>\n",
|
| 1649 |
+
" <td>0.2024</td>\n",
|
| 1650 |
+
" </tr>\n",
|
| 1651 |
+
" <tr>\n",
|
| 1652 |
+
" <th>47</th>\n",
|
| 1653 |
+
" <td>0.0000</td>\n",
|
| 1654 |
+
" <td>0.9551</td>\n",
|
| 1655 |
+
" <td>0.0449</td>\n",
|
| 1656 |
+
" </tr>\n",
|
| 1657 |
+
" </tbody>\n",
|
| 1658 |
+
"</table>\n",
|
| 1659 |
+
"</div>"
|
| 1660 |
+
],
|
| 1661 |
+
"text/plain": [
|
| 1662 |
+
" C L I\n",
|
| 1663 |
+
"0 0.0000 0.4412 0.5588\n",
|
| 1664 |
+
"1 0.0000 0.1282 0.8718\n",
|
| 1665 |
+
"2 0.0103 0.9684 0.0213\n",
|
| 1666 |
+
"3 0.1425 0.6402 0.2173\n",
|
| 1667 |
+
"4 0.0000 0.4368 0.5632\n",
|
| 1668 |
+
"5 0.4113 0.5611 0.0276\n",
|
| 1669 |
+
"6 0.0000 0.0833 0.9167\n",
|
| 1670 |
+
"7 0.0000 0.1084 0.8916\n",
|
| 1671 |
+
"8 0.0000 0.2813 0.7187\n",
|
| 1672 |
+
"9 0.0000 0.1603 0.8397\n",
|
| 1673 |
+
"10 0.0000 0.3995 0.6005\n",
|
| 1674 |
+
"11 0.0656 0.8952 0.0392\n",
|
| 1675 |
+
"12 0.0000 0.1925 0.8075\n",
|
| 1676 |
+
"13 0.0000 0.4750 0.5250\n",
|
| 1677 |
+
"14 0.0000 0.1009 0.8991\n",
|
| 1678 |
+
"15 0.0000 0.7522 0.2478\n",
|
| 1679 |
+
"16 0.0000 0.5647 0.4353\n",
|
| 1680 |
+
"17 0.0000 0.1440 0.8560\n",
|
| 1681 |
+
"18 0.0010 0.9841 0.0150\n",
|
| 1682 |
+
"19 0.0000 0.2770 0.7230\n",
|
| 1683 |
+
"20 0.0000 0.1460 0.8540\n",
|
| 1684 |
+
"21 0.5857 0.3897 0.0246\n",
|
| 1685 |
+
"22 0.0000 0.3768 0.6232\n",
|
| 1686 |
+
"23 0.0000 0.1754 0.8246\n",
|
| 1687 |
+
"24 0.0000 0.1023 0.8977\n",
|
| 1688 |
+
"25 0.0000 0.9993 0.0007\n",
|
| 1689 |
+
"26 0.0000 0.9722 0.0277\n",
|
| 1690 |
+
"27 0.0000 0.1487 0.8513\n",
|
| 1691 |
+
"28 0.3471 0.6463 0.0066\n",
|
| 1692 |
+
"29 0.0000 0.0935 0.9065\n",
|
| 1693 |
+
"30 0.0000 0.0681 0.9319\n",
|
| 1694 |
+
"31 0.0000 0.0930 0.9070\n",
|
| 1695 |
+
"32 0.0000 0.0949 0.9051\n",
|
| 1696 |
+
"33 0.0000 0.1731 0.8269\n",
|
| 1697 |
+
"34 0.0000 0.4813 0.5187\n",
|
| 1698 |
+
"35 0.0000 0.1585 0.8415\n",
|
| 1699 |
+
"36 0.0002 0.9989 0.0008\n",
|
| 1700 |
+
"37 0.0000 0.4955 0.5045\n",
|
| 1701 |
+
"38 0.0334 0.9617 0.0049\n",
|
| 1702 |
+
"39 0.7391 0.2608 0.0001\n",
|
| 1703 |
+
"40 0.7930 0.2069 0.0001\n",
|
| 1704 |
+
"41 0.0066 0.9888 0.0045\n",
|
| 1705 |
+
"42 0.0000 0.1184 0.8816\n",
|
| 1706 |
+
"43 0.0000 0.3498 0.6502\n",
|
| 1707 |
+
"44 0.0014 0.9359 0.0627\n",
|
| 1708 |
+
"45 0.0000 0.8535 0.1464\n",
|
| 1709 |
+
"46 0.0000 0.7976 0.2024\n",
|
| 1710 |
+
"47 0.0000 0.9551 0.0449"
|
| 1711 |
+
]
|
| 1712 |
+
},
|
| 1713 |
+
"execution_count": 68,
|
| 1714 |
+
"metadata": {},
|
| 1715 |
+
"output_type": "execute_result"
|
| 1716 |
+
}
|
| 1717 |
+
],
|
| 1718 |
+
"source": [
|
| 1719 |
+
"temp3"
|
| 1720 |
+
]
|
| 1721 |
+
},
|
| 1722 |
+
{
|
| 1723 |
+
"cell_type": "code",
|
| 1724 |
+
"execution_count": 8,
|
| 1725 |
+
"metadata": {},
|
| 1726 |
+
"outputs": [
|
| 1727 |
+
{
|
| 1728 |
+
"data": {
|
| 1729 |
+
"text/html": [
|
| 1730 |
+
"<div>\n",
|
| 1731 |
+
"<style scoped>\n",
|
| 1732 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1733 |
+
" vertical-align: middle;\n",
|
| 1734 |
+
" }\n",
|
| 1735 |
+
"\n",
|
| 1736 |
+
" .dataframe tbody tr th {\n",
|
| 1737 |
+
" vertical-align: top;\n",
|
| 1738 |
+
" }\n",
|
| 1739 |
+
"\n",
|
| 1740 |
+
" .dataframe thead th {\n",
|
| 1741 |
+
" text-align: right;\n",
|
| 1742 |
+
" }\n",
|
| 1743 |
+
"</style>\n",
|
| 1744 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1745 |
+
" <thead>\n",
|
| 1746 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1747 |
+
" <th></th>\n",
|
| 1748 |
+
" <th>sample_id_paired</th>\n",
|
| 1749 |
+
" <th>pair_id</th>\n",
|
| 1750 |
+
" <th>patient_id</th>\n",
|
| 1751 |
+
" <th>post_C</th>\n",
|
| 1752 |
+
" <th>post_L</th>\n",
|
| 1753 |
+
" <th>post_I</th>\n",
|
| 1754 |
+
" </tr>\n",
|
| 1755 |
+
" </thead>\n",
|
| 1756 |
+
" <tbody>\n",
|
| 1757 |
+
" <tr>\n",
|
| 1758 |
+
" <th>2401</th>\n",
|
| 1759 |
+
" <td>AR-024_1-DF0</td>\n",
|
| 1760 |
+
" <td>AR-024_10</td>\n",
|
| 1761 |
+
" <td>AR-024</td>\n",
|
| 1762 |
+
" <td>0.000000</td>\n",
|
| 1763 |
+
" <td>0.181853</td>\n",
|
| 1764 |
+
" <td>8.181471e-01</td>\n",
|
| 1765 |
+
" </tr>\n",
|
| 1766 |
+
" <tr>\n",
|
| 1767 |
+
" <th>2357</th>\n",
|
| 1768 |
+
" <td>AR-024_3-DF</td>\n",
|
| 1769 |
+
" <td>AR-024_3</td>\n",
|
| 1770 |
+
" <td>AR-024</td>\n",
|
| 1771 |
+
" <td>0.747905</td>\n",
|
| 1772 |
+
" <td>0.252095</td>\n",
|
| 1773 |
+
" <td>7.417523e-08</td>\n",
|
| 1774 |
+
" </tr>\n",
|
| 1775 |
+
" <tr>\n",
|
| 1776 |
+
" <th>2378</th>\n",
|
| 1777 |
+
" <td>AR-024_8-DF</td>\n",
|
| 1778 |
+
" <td>AR-024_8</td>\n",
|
| 1779 |
+
" <td>AR-024</td>\n",
|
| 1780 |
+
" <td>0.688672</td>\n",
|
| 1781 |
+
" <td>0.311328</td>\n",
|
| 1782 |
+
" <td>5.231539e-08</td>\n",
|
| 1783 |
+
" </tr>\n",
|
| 1784 |
+
" <tr>\n",
|
| 1785 |
+
" <th>2189</th>\n",
|
| 1786 |
+
" <td>AR-067_1-DF</td>\n",
|
| 1787 |
+
" <td>AR-067_1</td>\n",
|
| 1788 |
+
" <td>AR-067</td>\n",
|
| 1789 |
+
" <td>0.000000</td>\n",
|
| 1790 |
+
" <td>0.997268</td>\n",
|
| 1791 |
+
" <td>2.731921e-03</td>\n",
|
| 1792 |
+
" </tr>\n",
|
| 1793 |
+
" <tr>\n",
|
| 1794 |
+
" <th>2480</th>\n",
|
| 1795 |
+
" <td>AR-081_1-DF</td>\n",
|
| 1796 |
+
" <td>AR-081_1</td>\n",
|
| 1797 |
+
" <td>AR-081</td>\n",
|
| 1798 |
+
" <td>0.000000</td>\n",
|
| 1799 |
+
" <td>0.121702</td>\n",
|
| 1800 |
+
" <td>8.782983e-01</td>\n",
|
| 1801 |
+
" </tr>\n",
|
| 1802 |
+
" <tr>\n",
|
| 1803 |
+
" <th>...</th>\n",
|
| 1804 |
+
" <td>...</td>\n",
|
| 1805 |
+
" <td>...</td>\n",
|
| 1806 |
+
" <td>...</td>\n",
|
| 1807 |
+
" <td>...</td>\n",
|
| 1808 |
+
" <td>...</td>\n",
|
| 1809 |
+
" <td>...</td>\n",
|
| 1810 |
+
" </tr>\n",
|
| 1811 |
+
" <tr>\n",
|
| 1812 |
+
" <th>469</th>\n",
|
| 1813 |
+
" <td>Sero-256-DF_1</td>\n",
|
| 1814 |
+
" <td>Sero-256_1</td>\n",
|
| 1815 |
+
" <td>Sero-256</td>\n",
|
| 1816 |
+
" <td>0.000000</td>\n",
|
| 1817 |
+
" <td>0.169196</td>\n",
|
| 1818 |
+
" <td>8.308039e-01</td>\n",
|
| 1819 |
+
" </tr>\n",
|
| 1820 |
+
" <tr>\n",
|
| 1821 |
+
" <th>499</th>\n",
|
| 1822 |
+
" <td>Sero-258-DF_3</td>\n",
|
| 1823 |
+
" <td>Sero-258_3</td>\n",
|
| 1824 |
+
" <td>Sero-258</td>\n",
|
| 1825 |
+
" <td>0.000000</td>\n",
|
| 1826 |
+
" <td>0.936023</td>\n",
|
| 1827 |
+
" <td>6.397652e-02</td>\n",
|
| 1828 |
+
" </tr>\n",
|
| 1829 |
+
" <tr>\n",
|
| 1830 |
+
" <th>530</th>\n",
|
| 1831 |
+
" <td>Sero-258-DF_6</td>\n",
|
| 1832 |
+
" <td>Sero-258_6</td>\n",
|
| 1833 |
+
" <td>Sero-258</td>\n",
|
| 1834 |
+
" <td>0.000000</td>\n",
|
| 1835 |
+
" <td>0.743152</td>\n",
|
| 1836 |
+
" <td>2.568480e-01</td>\n",
|
| 1837 |
+
" </tr>\n",
|
| 1838 |
+
" <tr>\n",
|
| 1839 |
+
" <th>641</th>\n",
|
| 1840 |
+
" <td>Sero-267-DF_1</td>\n",
|
| 1841 |
+
" <td>Sero-267_1</td>\n",
|
| 1842 |
+
" <td>Sero-267</td>\n",
|
| 1843 |
+
" <td>0.000000</td>\n",
|
| 1844 |
+
" <td>0.520532</td>\n",
|
| 1845 |
+
" <td>4.794680e-01</td>\n",
|
| 1846 |
+
" </tr>\n",
|
| 1847 |
+
" <tr>\n",
|
| 1848 |
+
" <th>609</th>\n",
|
| 1849 |
+
" <td>Sero-277-DF_1</td>\n",
|
| 1850 |
+
" <td>Sero-277_1</td>\n",
|
| 1851 |
+
" <td>Sero-277</td>\n",
|
| 1852 |
+
" <td>0.000000</td>\n",
|
| 1853 |
+
" <td>0.994670</td>\n",
|
| 1854 |
+
" <td>5.329520e-03</td>\n",
|
| 1855 |
+
" </tr>\n",
|
| 1856 |
+
" </tbody>\n",
|
| 1857 |
+
"</table>\n",
|
| 1858 |
+
"<p>85 rows × 6 columns</p>\n",
|
| 1859 |
+
"</div>"
|
| 1860 |
+
],
|
| 1861 |
+
"text/plain": [
|
| 1862 |
+
" sample_id_paired pair_id patient_id post_C post_L post_I\n",
|
| 1863 |
+
"2401 AR-024_1-DF0 AR-024_10 AR-024 0.000000 0.181853 8.181471e-01\n",
|
| 1864 |
+
"2357 AR-024_3-DF AR-024_3 AR-024 0.747905 0.252095 7.417523e-08\n",
|
| 1865 |
+
"2378 AR-024_8-DF AR-024_8 AR-024 0.688672 0.311328 5.231539e-08\n",
|
| 1866 |
+
"2189 AR-067_1-DF AR-067_1 AR-067 0.000000 0.997268 2.731921e-03\n",
|
| 1867 |
+
"2480 AR-081_1-DF AR-081_1 AR-081 0.000000 0.121702 8.782983e-01\n",
|
| 1868 |
+
"... ... ... ... ... ... ...\n",
|
| 1869 |
+
"469 Sero-256-DF_1 Sero-256_1 Sero-256 0.000000 0.169196 8.308039e-01\n",
|
| 1870 |
+
"499 Sero-258-DF_3 Sero-258_3 Sero-258 0.000000 0.936023 6.397652e-02\n",
|
| 1871 |
+
"530 Sero-258-DF_6 Sero-258_6 Sero-258 0.000000 0.743152 2.568480e-01\n",
|
| 1872 |
+
"641 Sero-267-DF_1 Sero-267_1 Sero-267 0.000000 0.520532 4.794680e-01\n",
|
| 1873 |
+
"609 Sero-277-DF_1 Sero-277_1 Sero-277 0.000000 0.994670 5.329520e-03\n",
|
| 1874 |
+
"\n",
|
| 1875 |
+
"[85 rows x 6 columns]"
|
| 1876 |
+
]
|
| 1877 |
+
},
|
| 1878 |
+
"execution_count": 8,
|
| 1879 |
+
"metadata": {},
|
| 1880 |
+
"output_type": "execute_result"
|
| 1881 |
+
}
|
| 1882 |
+
],
|
| 1883 |
+
"source": [
|
| 1884 |
+
"temp2 = real_data_test[real_data_test.pair_id.isin(real_data_test_lc.pair_id.unique())]\n",
|
| 1885 |
+
"temp2[['sample_id_paired', 'pair_id', 'patient_id', 'post_C', 'post_L', 'post_I']].drop_duplicates().sort_values('sample_id_paired')"
|
| 1886 |
+
]
|
| 1887 |
+
},
|
| 1888 |
+
{
|
| 1889 |
+
"cell_type": "code",
|
| 1890 |
+
"execution_count": 46,
|
| 1891 |
+
"metadata": {},
|
| 1892 |
+
"outputs": [
|
| 1893 |
+
{
|
| 1894 |
+
"data": {
|
| 1895 |
+
"text/plain": [
|
| 1896 |
+
"(2539, 21)"
|
| 1897 |
+
]
|
| 1898 |
+
},
|
| 1899 |
+
"execution_count": 46,
|
| 1900 |
+
"metadata": {},
|
| 1901 |
+
"output_type": "execute_result"
|
| 1902 |
+
}
|
| 1903 |
+
],
|
| 1904 |
+
"source": [
|
| 1905 |
+
"real_data_test_lc.shape"
|
| 1906 |
+
]
|
| 1907 |
+
},
|
| 1908 |
{
|
| 1909 |
"cell_type": "code",
|
| 1910 |
"execution_count": null,
|