# Here there is some discussions about what parameters to use to rank genes for fgsea: https://github.com/ctlab/fgsea/issues/50
combo<-FindMarkers(macrophage.L,ident.1="OVA.Combo",ident.2="liOVA",min.pct=0.01,logfc.threshold=0,min.cells.feature=1,min.cells.group=1)# used min.pct = -Inf or 0.01
res.OVA<-fgsea(pathways=miDB_sig4.MLS,stats=OVA.ranks,minSize=0,maxSize=500,eps=0)# nPermSimple=500000 long calculation, saved RDS, needed because it cant calculate pval for some pathways due to high variability
merge.results1[merge.results1=="GOCC_MHC_CLASS_II_PROTEIN_COMPLEX"]<-"MHC-II protein complex"
merge.results1[merge.results1=="GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_OF_EXOGENOUS_PEPTIDE_ANTIGEN_VIA_MHC_CLASS_I_TAP_INDEPENDENT"]<-"Antigen processing and presentation"
# Order in the way we want to see
merge.results1$pathway<-factor(merge.results1$pathway,levels=c("IFNa response (Cilenti et all)",
combo<-FindMarkers(macrophage.T,ident.1="OVA.Combo",ident.2="liOVA",min.pct=0.01,logfc.threshold=0,min.cells.feature=1,min.cells.group=1)# used min.pct = -Inf or 0.01
merge.results1[merge.results1=="GOCC_MHC_CLASS_II_PROTEIN_COMPLEX"]<-"MHC-II protein complex"
merge.results1[merge.results1=="GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_OF_EXOGENOUS_PEPTIDE_ANTIGEN_VIA_MHC_CLASS_I_TAP_INDEPENDENT"]<-"Antigen processing and presentation"
# Order in the way we want to see
merge.results1$pathway<-factor(merge.results1$pathway,levels=c("IFNa response (Cilenti et all)",
plot.b<-PlotStellare(obs1=obs1,features1=featuresCD8,valueG="Expansion.NewlablesG",i="Shared.CD8 T cells.expanded",group.by0="Orig",controGroup="Liver.TA33",noCtrlvsAll=T)
# "global_x" and "global_y" give the position in um, x and y in pixels: https://vizgen.github.io/vizgen-postprocessing/output_data_formats/detected_transcripts_format.html
# filter to retain only transcripts_B that are close to the transcripts_A analysed. This speed up the script. It looks only in a square of l=1.1*1.1*2d.