a, Schematics of activating P2 neurons for 7 days of group enrichment/social isolation. 22°C treatments (no thermoactivation) were used as controls. Flies in group enrichment/social isolation were kept at 28°C for 7 days to thermally activate P2 neurons. After 7 days of thermal activation (or no activation), sleep behavior was measured at 22°C. b and c, Sleep profile of UAS-dTRPA1/+ heterozygous control flies after group enrichment/social isolation at 22°C for 7 days or at 28°C for 7 days. d and e, Sleep profile of P2-GAL4/+ heterozygous control flies after group enrichment/social isolation at 22°C for 7 days or at 28°C for 7 days. f and g, Sleep profile of flies expressing UAS-dTRPA1 under the control of P2-GAL4 after group enrichment/social isolation at 22°C for 7 days or at 28°C for 7 days. h, Quantification (Mean±SEM with individual data points) of daily total sleep, daytime sleep and ZT0-4 sleep for experimental and heterozygous control flies grouped or isolated for 7 days with (28°C) or without (22°C) thermal activation of P2-GAL4 labelled neurons. Sleep profiles are displayed as the average proportion of time spent sleeping in consecutive 30min segments during a 24hr LD cycle; solid line, Mean; shaded area, ±SEM. For h, two-way ANOVA were used for detecting interactions between temperature treatment and group/isolation status. Šidák multiple comparisons tests were used for post-hoc analyses between group treated and isolated animals of the same genotype and temperature treatment, *P<0.05, **P<0.01, ***P<0.001, ****P<0.0001; b–h, N=29–32 animals. For N and P values, see the Source Data.