We developed two computational methods, CARE and TIDE, to predict response and resistance to targeted therapies and immunotherapies. CARE infers gene signatures of targeted therapy response based on finding genes interacting with the drug target genes from CCLE, CGP and CTRP compound screens on cancer cell lines. CARE shows superior performance on predicting patient response to targeted therapy and chemotherapy, and predicted novel synergistic drug combinations that were experimentally validated. TIDE infers tumor immune dysfunction and exclusion based on finding genes from TCGA gene expression data that interact with tumor infiltrating CD8 T cells to impact patient survival. Interestingly, the TIDE signatures computed from clinical data without immunotherapies can reliably predict the clinical response of melanoma patients for both anti-PD1 and anti-CTLA4 therapies, with higher accuracy than mutation load and other biomarkers.