Skip to content

Commit

Permalink
PTMMap relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Barrero Rodríguez committed Oct 24, 2024
1 parent ff4afb1 commit aa5e060
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion 2_ReportLimma_wo_GUI/app_wo_GUI.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library("logging")
library("yaml")

# Get get arguments
#configPath <- "D:\\ReportAnalysis\\test\\test7_Andrea\\2_ReportLimma_wo_GUI\\limma_params.yaml"
# configPath <- "D:\\ReportAnalysis\\2_ReportLimma_wo_GUI\\test\\test4\\limma_params_HFpEF_01.yaml"
args = commandArgs(trailingOnly=TRUE)
configPath <- args[1]

Expand Down
30 changes: 20 additions & 10 deletions 4_qTableReport/qReportMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,20 +389,26 @@ def qReportDesign(config, quan, qTableD, contrast):
q2info.columns = pd.MultiIndex.from_tuples([qTableD.columns[0] if n==0 else (i,'','') for n,i in enumerate(q2info.columns)])
qTableD = pd.merge(q2info, qTableD, how='right', on=[qTableD.columns[0]])

if config['plotFolder'] and os.path.exists(config['plotFolder'][0]):
if config['plotFolder']:# and os.path.exists(config['plotFolder'][0]):
qTableD = qTableD[[qTableD.columns[0]]].rename(columns={'':'NoFilt'}).join(qTableD)
plotted_q = [os.path.splitext(i)[0] for i in os.listdir(config['plotFolder'][0])]

ptmMapPath = config['plotFolder'][0] if config['plotFolder'][0] else os.path.join(config['outfolder'], f'PTMMaps/{contrast}/plots')
plotted_q = [os.path.splitext(i)[0] for i in os.listdir(ptmMapPath)]

ptmMapPathExcel = config['plotFolder'][0] if config['plotFolder'][0] else f'../../../PTMMaps/{contrast}/plots'
qTableD[qTableD.columns[0]] = \
[f"=HYPERLINK(\"{os.path.join(config['plotFolder'][0], i)}.html\", \"{i}\")" if i in plotted_q else '' if i=='Sum' else i for i in qTableD.iloc[:, 0]]
[f"=HYPERLINK(\"{os.path.join(ptmMapPathExcel, i)}.html\", \"{i}\")" if i in plotted_q else '' if i=='Sum' else i for i in qTableD.iloc[:, 0]]

if len(config['plotFolder'])>1 and os.path.exists(config['plotFolder'][1]):
if len(config['plotFolder'])>1: #and os.path.exists(config['plotFolder'][1]):
qTableD = qTableD[[qTableD.columns[1]]].rename(columns={'':'Filt'}).join(qTableD)
plotted_q = [os.path.splitext(i)[0] for i in os.listdir(config['plotFolder'][1])]

ptmMapPath = config['plotFolder'][1] if config['plotFolder'][1] else os.path.join(config['outfolder'], f'PTMMaps/{contrast}/plots_FDR')
plotted_q = [os.path.splitext(i)[0] for i in os.listdir(ptmMapPath)]

ptmMapPathExcel = config['plotFolder'][1] if config['plotFolder'][1] else f'../../../PTMMaps/{contrast}/plots_FDR'
qTableD[qTableD.columns[0]] = \
[f"=HYPERLINK(\"{os.path.join(config['plotFolder'][1], i)}.html\", \"{i}\")" if i in plotted_q else '' if i=='Sum' else i for i in qTableD.iloc[:, 0]]
[f"=HYPERLINK(\"{os.path.join(ptmMapPathExcel, i)}.html\", \"{i}\")" if i in plotted_q else '' if i=='Sum' else i for i in qTableD.iloc[:, 0]]



return qTableD


Expand Down Expand Up @@ -451,8 +457,12 @@ def qReportMergeUpDown(params):
df_out = pd.DataFrame()
for col in dfup_wo.columns:
if 'sig' in col[1]:
df_out[('up', *col)] = dfup_wo[col]
df_out[('down', *col)] = dfdo_wo[col]
if col[1] == 'NMsig':
df_out[('up (NM decreased)', *col)] = dfup_wo[col]
df_out[('down (NM increased)', *col)] = dfdo_wo[col]
else:
df_out[('up', *col)] = dfup_wo[col]
df_out[('down', *col)] = dfdo_wo[col]
elif 'Hypergeom' in col[0]:
df_out[('up', *col)] = dfup_wo[col]
df_out[('down', *col)] = dfdo_wo[col]
Expand Down
8 changes: 6 additions & 2 deletions 4_qTableReport/qReportMaker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,13 @@ values_pivot: x-PSM
# Plot path: Path to the folder containing Cristina Plots
# - /Path/to/CompletePlot
# - /Path/to/FilteredPlot

# Leave it blank to use default folder:
# - [outfolder]/PTMMaps/{groups}/plots
# - [outfolder]/PTMMaps/{groups}/plots_FDR
plotFolder:
- D:\CNIC\Scripts\ReportStats\test\Plots
- D:\CNIC\Scripts\ReportStats\test\Plots_FDR
-
-

n_cpu: 8

Expand Down

0 comments on commit aa5e060

Please sign in to comment.